private static void OnEndNewTransitionEvent()
 {
     if (StateTransitionGUI.startNewTranstion)
     {
         Event e = Event.current;
         if (e.type == EventType.MouseMove)
         {
             StateTransitionGUI.toPosition = StateMachineUtils.MousePos2MachineGridPos(e.mousePosition);
             e.Use();
         }
         if (e.isMouse)
         {
             if (e.button == 0)
             {
                 foreach (var item in MachineStateGUIDataControl.allMachineStateGUI)
                 {
                     if (StateMachineUtils.MachineGridRectContainsMousePos(e.mousePosition, item.GUIRect))
                     {
                         MachineDataController.AddNewTransitionGUI(StateTransitionGUI.startPositionMs, item.state);
                         break;
                     }
                 }
                 StateTransitionGUI.startNewTranstion = false;
                 e.Use();
                 StateMachineEditorWindow.Instance.wantsMouseMove = false;
             }
             else if (e.button == 1)
             {
                 StateTransitionGUI.startNewTranstion = false;
                 e.Use();
                 StateMachineEditorWindow.Instance.wantsMouseMove = false;
             }
         }
     }
 }
示例#2
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);
        }