Updating editor GUI on button press

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 ();*/
    }

instead of doing this extra crap. i suggest you get the unity 4.6 beta all you gotta do is drag a button in and add a code it will automatically do on click.

i suggest you watch this:


Unity 4.6 Beta Download:
http://unity3d.com/unity/beta/4.6

To be extra clear I’m working with the Editor GUI, so this is of no use in this case :slight_smile: Just trying to make my inspector items more dynamic, being able to add/remove and rearrange fields on the go. My only issue being updating the editor to accomodate for the changes - I’ve tried Repaint(); but it’s not helped me so far, maybe I’m using it incorrectly though.