public override void OnInspectorGUI() { base.OnInspectorGUI(); StepObject myTarget = (StepObject)target; //get all the steps List <string> stepsName = new List <string>(Utility.getProgressionSteps().getSteps()); stepsName.Add("Add new step"); //display all the steps and let the player select one int tmpSelect = EditorGUILayout.Popup("Listened step", Utility.getProgressionSteps().getSteps().IndexOf(myTarget.getListenedStep()), stepsName.ToArray()); //if "Add new step" is selected if (tmpSelect == stepsName.Count - 1) { AddStepWindow.showWindow(); } else { //set the listenedStep depending on the selectedIndex myTarget.setListenedStep(Utility.getProgressionSteps().getSteps()[tmpSelect]); Undo.RegisterUndo(myTarget, "Change listened step"); } }