I’m trying to create a layout for an editor aimed to make Element lists in the inspector more user friendly. Right now I’m building a column of ObjectFields from an ArrayList, but I’d like to add/remove items from the ArrayList through the press of a button. My biggest concern right now is updating the editor. I can easily edit the ArrayList, but I can’t update the amount of ObjectFields in the inspector. I’m at loss here really.
Here’s as far as I’ve gotten.
public override void OnInspectorGUI()
{
JEWaveManager waveManager = target as JEWaveManager;
ArrayList arr = new ArrayList();
arr.Add ("Element");
arr.Add ("Element");
Vector2 scrollPos = new Vector2 (0.0F, 0.0F);
/*GUILayout.BeginScrollView(scrollPos, GUILayout.Width (100), GUILayout.Height(100));*/
GUILayout.BeginVertical ();
Object source = null;
foreach (string s in arr)
EditorGUILayout.ObjectField(s, source, typeof(Object), true);
if (GUILayout.Button("New Item"))
{
arr.Add ("Element");
Repaint ();
}
GUILayout.EndVertical ();
/*GUILayout.EndScrollView ();*/
}