//----------------------------------------------------------------------- // // Copyright (c) Hutong Games LLC. All rights reserved. // //----------------------------------------------------------------------- using System; using UnityEditor; using UnityEngine; using HutongGames.PlayMaker; namespace HutongGames.PlayMakerEditor { /// /// Custom inspector for PlayMakerFSM /// [CustomEditor(typeof(PlayMakerFSM))] public class FsmComponentInspector : UnityEditor.Editor { private PlayMakerFSM fsmComponent; private FsmInspector fsmInspector; public void OnEnable() { fsmComponent = (PlayMakerFSM) target; fsmInspector = new FsmInspector(fsmComponent.Fsm) {UnityInspectorMode = true}; fsmInspector.EditButtonAction += () => { FsmEditorWindow.OpenInEditor(fsmComponent); }; FsmEditor.OnFsmChanged += CheckRefresh; } public void OnDisable() { FsmEditor.OnFsmChanged -= CheckRefresh; } public override void OnInspectorGUI() { fsmInspector.OnGUI(); } private void CheckRefresh(Fsm fsm) { if (fsm == fsmComponent.Fsm) { fsmInspector.Reset(); } } /// /// Actions can use OnSceneGUI to display interactive gizmos /// public void OnSceneGUI() { FsmEditor.OnSceneGUI(); } // These should be in FsmEditor, but keeping here for backward compatibility // Some third party tools may be using them... /// /// Open the specified FSM in the Playmaker Editor /// [Obsolete("Use FsmEditorWindow.OpenInEditor instead")] public static void OpenInEditor(PlayMakerFSM fsmComponent) { FsmEditorWindow.OpenInEditor(fsmComponent); } /// /// Open the specified FSM in the Playmaker Editor /// [Obsolete("Use FsmEditorWindow.OpenInEditor instead")] public static void OpenInEditor(Fsm fsm) { FsmEditorWindow.OpenInEditor(fsm.Owner as PlayMakerFSM); } /// /// Open the first PlayMakerFSM on a GameObject in the Playmaker Editor /// [Obsolete("Use FsmEditorWindow.OpenInEditor instead")] public static void OpenInEditor(GameObject go) { FsmEditorWindow.OpenInEditor(FsmSelection.FindFsmOnGameObject(go)); } } }