Skip to main content
2 of 2
Named includeChildren to make it explicit why that "true" is necessary.
Tim C
  • 645
  • 3
  • 11

You can't do this with ObjectField because Arrays are not Objects. You need to use a PropertyField instead of an ObjectField, which is more generic and can handle properties of any type.

Corrected code:

[CustomEditor(typeof(MyTile))] public class MyScriptEditor : Editor { override public void OnInspectorGUI() { var tile = target as MyTile; tile.variety = EditorGUILayout.Toggle("Hide Fields", tile.variety); if (tile.variety) { SerializedProperty tileProperty = serializedObject.FindProperty("varietyTiles"); if(EditorGUILayout.PropertyField(tileProperty, includeChildren:true)) { serializedObject.ApplyModifiedProperties(); } } } } 
Tim C
  • 645
  • 3
  • 11