Creating a custom inspector for a tool. In the tool, there is a list of custom objects, and I’m creating a custom inspector for this list. Inside of this custom object, there is another list, and for this nested list I’d like to draw the default list inspector.
To this end, I’ve tried using the FindProperty, and EditorGUILayout.PropertyField method but keep getting the error that “Type ‘CustomObj’ does not contain a definition for ‘FindProperty’”
The CustomObj is Serializable, so I’m not sure where I’ve gone wrong. Sample code below.
Main Class
[Serializable]
public class CustomObj {
public bool data1 = false;
public string someString;
public Transform[] nestedList = new Transform[1];
}
public class SomeTool:MonoBehaviour {
public CustomObj[] customList = null;
...
}
Editor Class
[CustomEditor(typeof(SomeTool))]
class SomeToolEditor:Editor {
private bool showAll = true;
public override void OnInspectorGUI() {
SomeTool script = target as SomeTool;
showAll = EditorGUILayout.Foldout( showAll, "Tools" );
if (showAll) {
foreach (CustomObj co in script.customList) {
EditorGUILayout.PropertyField(co.FindProperty("nestedList"));
}
}
}
}
I’ve tried setting CustomObj to inhereit MonoBehaviour w/ no success as well.