Hello,
I Want to disable and enable a single member according to some enum int the same class.
My editor code is:
void OnEnable()
{
myObject = serializedObject.FindProperty("myObject");
myEnum = serializedObject.FindProperty("myEnum");
}
public override void OnInspectorGUI()
{
DrawDefaultInspector();
if (myEnum.intValue == (int)someEnum.Custom)
{
EditorGUILayout.PropertyField(myObject,true);
}
else
{
GUI.enabled = false;
EditorGUILayout.PropertyField(myObject,true);
GUI.enabled = true;
}
serializedObject.ApplyModifiedProperties();
}
And the Editable class:
[Serializable]
public class someObject
{
public int val;
}
[CreateAssetMenu(fileName = "...", menuName = "...")]
public class QuestDefinition : ScriptableObject
{
... Other members
public someEnum myEnum= someEnum.Custom;
public someObject myObject;
}
The issue is if I dont add [HideInInspector] to myObject, it will be displayed twice, however if I do add it, the children wont be visible.
How can I achive the wanted result here?