What I Am Trying To Accomplish:
I have a list of objects in a custom editor and I wanted to make an area where you could enter valid arguments then hit add to add an element. I am making a special interface for this because there are spacial considerations and it is easier to think about the arguments in a spatial manner when laid out in this way.
What I Have:
I have drawn it in a PropertyDrawer for a ScriptableObject (MyObject) I made. It draws fine when the scriptableobject(MyObject) variable is inside the ScriptableObject (OtherObject) but I wanted to keep all the editor stuff inside the Editor folders to keep things clean. I am aware of the #if UNITY_EDITOR #endif things. So I tried to make the SerializedObject that I draw my SerializedProperty from to be OtherObjectEditor itself. It actually draws the interface fine but it disables the controls. I suspect this has something to with the cyclic reference.
What I Wanted To Know:
Is there a way to re-enable the controls? Is there a better way to do this while keeping my two conditions of Editor script seperation and the interface I want to draw? I am open to not using PropertyDrawers to draw this kind of thing but I do not know of any other way to draw it. Is there another way, all I have to do is draw popups and radio buttons so I need to control the rects they are drawn in so maybe there is?
[CustomEditor(typeof(OtherObject))]
public class OtherObjectEditor : Editor
{
[SerializeField] private MyObject _obj;
private SerializedObject _serial_obj;
private SerializedProperty _prop;
private void OnEnable()
{
_obj = ScriptableObject.CreateInstance<MyObject>();
_obj.Init();
_serial_obj = new SerializedObject(this);
_prop = _serial_obj.FindProperty("_obj");
}
private void SomeMethod()
{
//...
if (_prop != null)
{
EditorGUILayout.PropertyField(_prop);
}
//...
}
//other stuff....
}
[System.Serializable]
public class MyObject : ScriptableObject
{
[SerializeField] private int _myvariable;
//more variables and methods like this
public void Init()
{
//some intializing logic
}
}