public override void OnInspectorGUI() { ActionTool.EventManager manager = (ActionTool.EventManager)target; if (!manager.ReservedEventsAdded) { manager.AddReservedEvents(); } EditorGUI.BeginChangeCheck(); for (int i = 0; i < manager.EventIDs.Length; i++) { GPEventID id = manager.EventIDs[i]; if (id.ID < 0) { continue; } EditorGUILayout.BeginHorizontal(); string newName = EditorGUILayout.TextField(id.ID.ToString(), id.Name); id.Name = newName; //manager.CheckNames(id); if (GUILayout.Button("Remove")) { manager.RemoveEventName(id); i--; } EditorGUILayout.EndHorizontal(); } if (GUILayout.Button("Add Event")) { manager.AddEventName(); } /* * if (GUILayout.Button("Add Default Events")) * { * manager.AddReservedEvents(); * } */ if (GUILayout.Button("Refresh")) { manager.RefreshIDList(); } EditorGUI.EndChangeCheck(); }
// Draw the property inside the given rect public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { SerializedProperty idProperty = property.FindPropertyRelative("m_ID"); SerializedProperty nameProperty = property.FindPropertyRelative("m_name"); int currIdx = EventManager.Instance.IndexOfID(idProperty.intValue); int newIdx = EditorGUILayout.Popup(label.text, currIdx, EventManager.Instance.EventNames); if (newIdx != currIdx) { GPEventID evtID = EventManager.Instance.EventIDs[newIdx]; idProperty.intValue = evtID.ID; nameProperty.stringValue = evtID.Name; } }