Beispiel #1
0
        public void OnSelectionChange()
        {
            Selection.pa
            try
            {
                BinaryFormatter fomatter = new BinaryFormatter();
                using (FileStream fs = new FileStream(fullFileName, FileAccess.ReadWrite))
                {

                }
            }
            catch
            {

            }
            _record = Selection.activeObject as FsmRecord;
            if (_record == null && Selection.activeGameObject != null)
            {
                Fsm fsm = Selection.activeGameObject.GetComponent<Fsm>();
                if (fsm != null)
                    _record = fsm.Record;
            }

            CurrentState = null;

            Repaint();
        }
Beispiel #2
0
        void Callback_Window(int id)
        {
            int stateIndex = id - 1;
            FsmRecord.State thisWindowState = _record.States[stateIndex];
            for (int i = 0; i < thisWindowState.Actions.Count; ++i)
            {
                if (thisWindowState.Actions[i] != null)
                    GUILayout.Label(thisWindowState.Actions[i].GetType().Name.Replace("FsmAction_", ""));
            }

            GUI.DragWindow();

            Event e = Event.current;
            if (e.type == EventType.Used)
            {
                FsmRecord.State preState = CurrentState;

                CurrentState = _record.States[stateIndex];

                if (CurrentState != preState)
                {
                    _actionExpandStates.Clear();
                    for (int i = 0; i < CurrentState.Actions.Count; ++i)
                    {
                        _actionExpandStates.Add(CurrentState.Actions[i], false);
                    }
                }

                GUI.SetNextControlName("");
                GUI.FocusControl("");
                GUI.FocusWindow(id);
            }
        }
Beispiel #3
0
        void Update_OnTransitioning()
        {
            if (CurrentState == null)
                _transitionStartState = null;

            if (Event.current.type == EventType.Used && _transitionStartState != null)
            {
                FsmRecord.State selected = _record.States.Find(item => item.Rect.Contains(Event.current.mousePosition));
                if (selected != null && selected != _transitionStartState)
                {
                    //_transitionStartState.Transitions.Add(new FsmTransition { NextState = selected } );
                    Debug.Log(selected.Name);
                }

                _transitionStartState = null;
            }

            if (_transitionStartState == null)
                return;

            Color original = Handles.color;
            Handles.color = Color.black;
            //Handles.DrawLine(_currentState.Rect.center, Event.current.mousePosition);

            Vector3 dir = Event.current.mousePosition - CurrentState.Rect.center;
            Handles.Button(CurrentState.Rect.center, Quaternion.identity , dir.magnitude , dir.magnitude * 0.5f, Handles.CubeCap);
            Handles.color = original;

            Repaint();
        }
Beispiel #4
0
 void Menu_RemoveState(object stateObject)
 {
     FsmRecord.State selected = stateObject as FsmRecord.State;
     if (selected != null)
     {
         _record.States.Remove(selected);
         if (selected == CurrentState)
             CurrentState = null;
     }
 }
Beispiel #5
0
 void Menu_AddTransition(object stateObject)
 {
     if (CurrentState != null)
     {
          _transitionStartState = CurrentState;
     }
 }
Beispiel #6
0
        void Menu_AddState(object userData)
        {
            if (_record == null)
                return;

            Vector2 pos = (Vector2)userData;
            FsmRecord.State state = new FsmRecord.State();
            state.Rect = new Rect(pos, new Vector2(100, 60));
            _record.States.Add(state);

            if (_record.States.Count == 1)
            {
                _record.EntryState = state;
            }

            SaveRecords();
            Repaint();
        }