コード例 #1
0
        public static StateTransition AddNewStateTransition(MachineState fromState, MachineState toState)
        {
            if (fromState == null || toState == null)
            {
                return(null);
            }
            StateTransition st = new StateTransition();

            st.fromState = fromState;
            st.toState   = toState;
            fromState.stateTransitions.Add(st);
            transitions.Add(st);
            //Debug.Log("AddNewStateTransition :" + fromState.showContent.text + " to:" + toState.showContent.text);
            return(st);
        }
コード例 #2
0
        public static StateTransitionArrowLine AddStateTransitionToCreateArrowLine(StateTransition trans)
        {
            foreach (var item in allStateTransitionArrowLineList)
            {
                if (item.transitions[0].toState == trans.toState && item.transitions[0].fromState == trans.fromState)
                {
                    item.transitions.Add(trans);
                    return(item);
                }
            }
            StateTransitionArrowLine line = ScriptableObject.CreateInstance <StateTransitionArrowLine>();

            line.transitions.Add(trans);
            allStateTransitionArrowLineList.Add(line);
            return(line);
        }
コード例 #3
0
 public static void DeleteStateTransition(StateTransitionArrowLine line, StateTransition st)
 {
     if (line.transitions.Contains(st))
     {
         if (line.transitions.Count == 1)
         {
             StateTransitionArrowLineDataControl.DeleteStateTransitionArrowLine(line);
         }
         else
         {
             StateTransitionDataControl.DeleteStateTransition(st);
             line.transitions.Remove(st);
         }
         if (StateMachineEditorWindow.OnDeleteStateTransition != null)
         {
             StateMachineEditorWindow.OnDeleteStateTransition(st);
         }
     }
 }
コード例 #4
0
 protected override void OnInspectorGUI()
 {
     // base.OnInspectorGUI();
     GUILayout.BeginVertical("box");
     for (int i = 0; i < line.transitions.Count; i++)
     {
         StateTransition st   = line.transitions[i];
         MachineStateGUI mag0 = MachineStateGUIDataControl.GetMachineStateGUI(st.fromState);
         MachineStateGUI mag1 = MachineStateGUIDataControl.GetMachineStateGUI(st.toState);
         GUILayout.BeginHorizontal("box");
         GUILayout.Label(mag0.name + " -> " + mag1.name);
         if (line.transitions.Count > 1 && GUILayout.Button("-"))
         {
             MachineDataController.DeleteStateTransition(line, st);
             return;
         }
         GUILayout.EndHorizontal();
     }
     GUILayout.EndVertical();
 }
コード例 #5
0
 public static bool RemoveStateTransitionToDeleteArrowLine(StateTransition trans)
 {
     foreach (var item in allStateTransitionArrowLineList)
     {
         foreach (var t in item.transitions)
         {
             if (t == trans)
             {
                 if (item.transitions.Count == 1)
                 {
                     allStateTransitionArrowLineList.Remove(item);
                     Object.DestroyImmediate(item);
                     return(true);
                 }
                 else
                 {
                     item.transitions.Remove(trans);
                     return(true);
                 }
             }
         }
     }
     return(false);
 }