예제 #1
0
        static public void CreateNewModel(MachineStateGUI msg)
        {
            LogicObject          r  = CreateLogicObject("新建逻辑模块", msg.position);
            LogicObjectBehaviour be = new LogicObjectBehaviour();

            be.logicObj = r;
            msg.state.stateBaseBehaviours.Add(be);
            msg.name = r.name;
        }
        void CreateItem(MessageString ms)
        {
            LogicObject lo = JsonUtils.JsonToClassOrStruct <LogicObject>(ms.value);

            MachineStateGUI      msg = MachineDataController.AddNewMachineStateGUI(new Vector2(500, 450), lo.name, false);
            LogicObjectBehaviour be  = new LogicObjectBehaviour();

            be.logicObj = lo;
            msg.state.stateBaseBehaviours.Add(be);
            msg.name = lo.name;
            LogicSystemEditorWindow.AddLogicObject(lo);
        }
        public override void OnInspectorGUI()
        {
            targetObj = (LogicObjectBehaviour)target;
            logicObj  = targetObj.logicObj;
            GUILayout.Space(10);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label("ID :" + logicObj.id);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            //logicObj.name = EditorDrawGUIUtil.DrawBaseValue ("Name", logicObj.name).ToString();
            if (LogicSystemEditorWindow.data != null)
            {
                isStartModel = LogicSystemEditorWindow.data.startId == logicObj.id;
            }
            stateGUI.NormalStateColor = isStartModel ? UnityEditor.Graphs.Styles.Color.Yellow : UnityEditor.Graphs.Styles.Color.Gray;
            if (!isStartModel)
            {
                bool oldState = logicObj.isSupportAlwaysActive;
                logicObj.isSupportAlwaysActive = (bool)EditorDrawGUIUtil.DrawBaseValue("是否支持永远激活状态", logicObj.isSupportAlwaysActive);
                if (oldState != logicObj.isSupportAlwaysActive && logicObj.isSupportAlwaysActive)
                {
                    foreach (var item in stateGUI.FromArrowLines)
                    {
                        MachineDataController.DeleteStateTransitionArrowLine(item);
                    }
                }
                if (logicObj.isSupportAlwaysActive)
                {
                    stateGUI.NormalStateColor = UnityEditor.Graphs.Styles.Color.Red;
                }

                DrawNameAndClassListGUI("事件:", logicObj.events, LogicComponentType.Event);
                DrawNameAndClassListGUI("条件:", logicObj.conditions, LogicComponentType.Condition);
            }
            DrawNameAndClassListGUI("动作:", logicObj.actions, LogicComponentType.Action);

            string tempStr = "";

            foreach (int ch in logicObj.childObjects)
            {
                tempStr += ch + ",";
            }
            GUILayout.Label("Child ID:" + tempStr);
            GUILayout.Label("Pos:" + targetObj.logicObj.editorPos);
            GUILayout.Space(6);
            SaveToBackupGUI();
        }
예제 #4
0
        //public EditorWindow animatorWindow;
        static void Init()
        {
            data = LogicObjectDataController.GetDataFromFile(logicDataName);
            if (data.logicObjs.Count == 0)
            {
                LogicObject r = CreateLogicObject("开始", new Vector2(500, 400));
                data.startId = r.id;
            }

            Dictionary <int, MachineStateGUI> allState = new Dictionary <int, MachineStateGUI>();

            foreach (var item in data.logicObjs)
            {
                MachineStateGUI      msg = MachineDataController.AddNewMachineStateGUI(item.editorPos, item.name);
                LogicObjectBehaviour be  = new LogicObjectBehaviour();
                msg.state.stateBaseBehaviours.Add(be);
                be.state    = msg.state;
                be.logicObj = item;
                bool isStartModel = LogicSystemEditorWindow.data.startId == item.id;
                msg.NormalStateColor = isStartModel ? UnityEditor.Graphs.Styles.Color.Yellow : UnityEditor.Graphs.Styles.Color.Gray;
                if (!isStartModel && item.isSupportAlwaysActive)
                {
                    msg.NormalStateColor = UnityEditor.Graphs.Styles.Color.Red;
                }
                allState.Add(item.id, msg);
            }
            foreach (var item in data.logicObjs)
            {
                foreach (var child in item.childObjects)
                {
                    MachineDataController.AddNewTransitionGUI(allState[item.id].state, allState[child].state);
                }
            }

            StateMachineEditorWindow.OnDrawLeftPartGUI       = OnGUI;
            StateMachineEditorWindow.OnCreateMachineStateGUI = CreateNewModel;

            internalValueTypeList.Add(typeof(string).FullName);
            internalValueTypeList.Add(typeof(int).FullName);
            internalValueTypeList.Add(typeof(float).FullName);
            internalValueTypeList.Add(typeof(Vector2).FullName);
            internalValueTypeList.Add(typeof(Vector3).FullName);
            internalValueTypeList.Add(typeof(bool).FullName);
        }
예제 #5
0
 static public void UpdateStateDataInfo()
 {
     if (data != null && StateMachineEditorWindow.Instance != null)
     {
         foreach (var item in MachineStateGUIDataControl.allMachineStateGUI)
         {
             LogicObjectBehaviour be = (LogicObjectBehaviour)item.state.stateBaseBehaviours[0];
             be.logicObj.name      = item.name;
             be.logicObj.editorPos = item.position;
             List <int> childList = new List <int>();
             foreach (StateTransition st in item.state.stateTransitions)
             {
                 LogicObjectBehaviour be1 = (LogicObjectBehaviour)st.toState.stateBaseBehaviours[0];
                 childList.Add(be1.logicObj.id);
             }
             be.logicObj.childObjects = childList;
         }
     }
 }