Hey guys, I am trying to make a nice UI for our tester to go into Unity and allow them to adjust variables as they test. I am trying to make a quick and simple inspector GUI for them to use to add and delete stuff in List. So far I can’t figure out how to get the inspector editor to work with the editor or if this is even possible. Basically I have a button that allows the tester to add an object such as an enemy then they set how many we are going to need. When I try and add to the list, I get a object ref not set to an instance error. Is there anything I can do to fix this?
public class PoolEditor : Editor
{
public override void OnInspectorGUI()
{
PoolManager t = (PoolManager)target;
DrawDefaultInspector();
if (GUILayout.Button("Add Object"))
{
PoolManager.instance.Objects.Add(null);
PoolManager.instance.ObjectToSpawnNumbers.Add(0);
}
for (int i = 0; i < PoolManager.instance.Objects.Count; i++)
{
PoolManager.instance.Objects[i] = EditorGUILayout.ObjectField("Object" + i + ": ", PoolManager.instance.Objects[i], typeof(GameObject)) as GameObject;
PoolManager.instance.ObjectToSpawnNumbers[i] = EditorGUILayout.IntField("Amount: ", PoolManager.instance.ObjectToSpawnNumbers[i]);
if (GUILayout.Button("Remove Object"))
{
PoolManager.instance.Objects.RemoveAt(i);
PoolManager.instance.Objects.RemoveAt(i);
}
}
}
}