protected override void OnSPInspectorGUI() { this.serializedObject.Update(); this.DrawDefaultInspectorExcept("StartingCameraStyle"); this.serializedObject.ApplyModifiedProperties(); var targ = this.target as CameraMovementController; var states = this.GetMovementControllerStates(); var ids = new List <string>(); ids.Add("None"); ids.AddRange(DefaultComponentChoiceSelector.GetUniqueComponentNames(states)); int i = (targ.StartingCameraStyle != null) ? ids.IndexOf(targ.StartingCameraStyle.GetType().Name) : -1; if (i < 0) { i = 0; } EditorGUI.BeginChangeCheck(); i = EditorGUILayout.Popup("Starting Camera Style", i, ids.ToArray()); if (EditorGUI.EndChangeCheck()) { if (i <= 0) { targ.StartingCameraStyle = null; } else { targ.StartingCameraStyle = states[i - 1] as ICameraMovementControllerState; } this.serializedObject.Update(); } if (Application.isPlaying) { try { var nm = ids[states.IndexOf(targ.States.Current) + 1]; EditorGUILayout.HelpBox("Currently active state is '" + nm + "'.", MessageType.Info); } catch { } } }
protected override void OnBeforeGUI() { var componentNames = DefaultComponentChoiceSelector.GetUniqueComponentNames(this.Components).ToArray(); _entries.Clear(); Component c; string nm; for (int i = 0; i < this.Components.Length; i++) { c = this.Components[i]; nm = componentNames[i]; if (c is IObservableTrigger) { var arr = (c as IObservableTrigger).GetTriggers(); if (arr.Length == 1) { var tid = arr[0].ObservableTriggerId; var scont = string.IsNullOrEmpty(tid) ? nm : string.Format("{0} -> {1}", nm, tid); _entries.Add(new TriggerEntry() { component = c, triggerId = tid, popupName = new GUIContent(scont) }); } else if (arr.Length > 1) { for (int j = 0; j < arr.Length; j++) { var tid = arr[j].ObservableTriggerId; var scont = string.IsNullOrEmpty(tid) ? string.Format("{0}/Trigger_{1}", nm, j) : string.Format("{0}/{1}", nm, tid); _entries.Add(new TriggerEntry() { component = c, triggerId = tid, popupName = new GUIContent(scont) }); } } } } }