コード例 #1
0
        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;
            }
        }
コード例 #2
0
        public override void OnInspectorGUI()
        {
            ActionMachineTest actionMachine = (ActionMachineTest)target;

            base.OnInspectorGUI();

            if (GUILayout.Button("打开编辑器"))
            {
                ActionEditorWindow.ShowEditor(actionMachine.gameObject, actionMachine.config);
            }
        }
コード例 #3
0
 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)}脚本");
     }
 }
コード例 #4
0
        private void Check()
        {
            if (!isActionMachineValid)
            {
                actionMachineObj = null;
                actionMachine    = null;
            }

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

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