Rowlan
1
I have these arrays in the gameobject, one is drawn using Unity’s internal editor, the other with my custom inspector, just to showcase my problem:
public Object[] objectsUnityEditor = new Object[0];
[HideInInspector]
public Object[] objectsCustomEditor = new Object[0];
The problem: It doesn’t work in a custom inspector. This here:
public override void OnInspectorGUI()
{
serializedObject.Update();
base.DrawDefaultInspector();
EditorGUILayout.PropertyField(objectsCustomEditor);
serializedObject.ApplyModifiedProperties();
}
Results in the array editor for objectsCustomEditor not being drawn, but the automatic for objectsUnityEditor is displayed:

Question: What do I have to do that PropertyField used Unity’s internal editor for the array?
Rowlan
2
Update: I figured how to create an editor via code, but I rather use Unity’s internal one for the array.
Code looks like this:
bool expanded = true;
public override void OnInspectorGUI()
{
serializedObject.Update();
base.DrawDefaultInspector();
// TODO: this isn't working:
// EditorGUILayout.PropertyField(objectsCustomEditor);
// custom array
expanded = EditorGUILayout.Foldout(expanded, new GUIContent("Objects Custom Editor"), true);
if (expanded)
{
EditorGUI.indentLevel++;
{
objectsCustomEditor.arraySize = EditorGUILayout.IntField("Size", objectsCustomEditor.arraySize);
for (int i = 0; i < objectsCustomEditor.arraySize; i++)
{
EditorGUILayout.PropertyField(objectsCustomEditor.GetArrayElementAtIndex(i), new GUIContent(string.Format("Element {0}", i)));
}
}
EditorGUI.indentLevel--;
}
serializedObject.ApplyModifiedProperties();
}
and would look like this:

But doing it manually just isn’t future proof.