Hello,
I’ve been searching everywhere for a solution, but cannot find it. I want to set parameters of some array as prefabs, and decided to use a custom inspector to edit these prefabs (rather than hard coding each individual class object.
Here’s what I have:
using UnityEngine;
using System.Collections;
public class Something : MonoBehaviour {
public enum MovementTypes { None, Move, Jump};
public MovementTypes[,] Movement = new MovementTypes[5,5];
public string Name;
}
And my Editor/ has
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor(typeof(Something))]
public class SomethingEditor : Editor {
public override void OnInspectorGUI()
{
Something myS = (Something)target;
myS.Name = EditorGUILayout.TextField("Type Name", myS.Name);
for (int y = 0; y < 5; y++)
{
EditorGUILayout.BeginHorizontal ();
for (int x = 0; x < 5; x++)
myS.Movement[x, y] = (Something.MovementTypes)EditorGUILayout.EnumPopup(myS.Movement[x, y]);
EditorGUILayout.EndHorizontal ();
}
}
}
This code graces me with the following errors:
- NullReferenceException: Object reference not set to an instance of an object
SomethingEditor.OnInspectorGUI () (at Assets/Editor/SomethingEditor.cs:17)
UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean forceDirty, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect, Boolean eyeDropperDirty) (at C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/Inspector/InspectorWindow.cs:1124)
UnityEditor.DockArea:OnGUI() - Unexpected top level layout group! Missing GUILayout.EndScrollView/EndVertical/EndHorizontal?
UnityEditor.DockArea:OnGUI()
I’ve tried a bunch of things, and nothing works. I cannot edit the 5x5 array. The only work around I can fathom right now is to make 25 separate variables…