private void OnPlayModeStateChanged(PlayModeStateChange state)
        {
            switch (state)
            {
            case PlayModeStateChange.EnteredPlayMode:
                actionMachineObj = null;
                actionMachine    = null;
                configAsset      = null;
                config           = null;
                break;

            case PlayModeStateChange.EnteredEditMode:
                //还原最后的选择
                GameObject        obj;
                ActionMachineTest amTest;
                if (!string.IsNullOrEmpty(lastEditorTargetPath) &&
                    (obj = GameObject.Find(lastEditorTargetPath)) != null &&
                    (amTest = obj.GetComponent <ActionMachineTest>()) != null)
                {
                    UpdateTarget(obj);
                    UpdateConfig(amTest.config);
                }
                lastEditorTargetPath = string.Empty;
                break;

            case PlayModeStateChange.ExitingEditMode:
                //记录最后的选择
                lastEditorTargetPath = actionMachineObj?.GetScenePath();
                break;
            }
        }
        public override void OnInspectorGUI()
        {
            ActionMachineTest actionMachine = (ActionMachineTest)target;

            base.OnInspectorGUI();

            if (GUILayout.Button("打开编辑器"))
            {
                ActionEditorWindow.ShowEditor(actionMachine.gameObject, actionMachine.config);
            }
        }
 public void UpdateTarget(GameObject target)
 {
     if (target == null)
     {
         throw new RuntimeException($"未选择目标");
     }
     actionMachineObj = target;
     actionMachine    = target.GetComponent <ActionMachineTest>();
     if (actionMachine == null)
     {
         actionMachineObj = null;
         throw new RuntimeException($"目标不存在{nameof(ActionMachineTest)}脚本");
     }
 }
        private void Check()
        {
            if (!isActionMachineValid)
            {
                actionMachineObj = null;
                actionMachine    = null;
            }

            if (!isConfigValid)
            {
                configAsset = null;
                config      = null;
            }

            //更新标题
            //this.titleContent = new GUIContent(configAsset != null ? $"编辑 {configAsset.name} " : $"动作编辑器");
        }