Пример #1
0
 public static GUIContent GetEventLabel(SkillTransition transition)
 {
     SkillEditorContent.EventLabel.set_text("...");
     SkillEditorContent.EventLabel.set_tooltip("");
     if (!SkillEvent.IsNullOrEmpty(transition.get_FsmEvent()))
     {
         SkillEditorContent.EventLabel.set_text(transition.get_FsmEvent().get_Name());
     }
     return(SkillEditorContent.EventLabel);
 }
        private static void CheckTransitionsForErrors(SkillState state)
        {
            List <string> list = new List <string>();

            SkillTransition[] transitions = state.get_Transitions();
            for (int i = 0; i < transitions.Length; i++)
            {
                SkillTransition fsmTransition = transitions[i];
                if (FsmEditorSettings.CheckForTransitionMissingEvent && string.IsNullOrEmpty(fsmTransition.get_EventName()))
                {
                    FsmErrorChecker.AddError(state, fsmTransition, Strings.get_FsmErrorChecker_TransitionMissingEventError());
                }
                if (FsmEditorSettings.CheckForDuplicateTransitionEvent && list.Contains(fsmTransition.get_EventName()))
                {
                    FsmErrorChecker.AddError(state, fsmTransition, Strings.get_FsmErrorChecker_DuplicateTransitionEventError());
                }
                if (!string.IsNullOrEmpty(fsmTransition.get_EventName()))
                {
                    list.Add(fsmTransition.get_EventName());
                }
                if (FsmEditorSettings.CheckForTransitionMissingTarget && string.IsNullOrEmpty(fsmTransition.get_ToState()))
                {
                    FsmErrorChecker.AddError(state, fsmTransition, Strings.get_FsmErrorChecker_TransitionMissingTargetError());
                }
                if (state.get_Fsm() != null)
                {
                    SkillEvent fsmEvent = fsmTransition.get_FsmEvent();
                    if (fsmEvent != null && fsmEvent.get_IsSystemEvent())
                    {
                        FsmErrorChecker.CheckSystemEventsForErrors(state, fsmTransition, fsmEvent);
                    }
                }
            }
        }
Пример #3
0
        private static void StateTools()
        {
            ToolWindow.Header(Strings.get_ToolWindow_Header_State_Tools());
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            if (GUILayout.Button(Strings.get_Command_Copy(), new GUILayoutOption[0]))
            {
                EditorCommands.CopyStateSelection();
            }
            EditorGUI.BeginDisabledGroup(!SkillEditor.Builder.CanPaste());
            if (GUILayout.Button(Strings.get_Command_Paste(), new GUILayoutOption[0]))
            {
                EditorCommands.PasteStates(FsmGraphView.GetViewCenter());
                SkillEditor.RepaintAll();
            }
            EditorGUI.EndDisabledGroup();
            if (GUILayout.Button(Strings.get_Command_Delete(), new GUILayoutOption[0]))
            {
                SkillEditor.RepaintAll();
                EditorCommands.DeleteMultiSelection();
            }
            GUILayout.EndHorizontal();
            if (GUILayout.Button(Strings.get_Command_Save_Selection_as_Template(), new GUILayoutOption[0]))
            {
                EditorCommands.SaveSelectionAsTemplate();
            }
            if (GUILayout.Button(Strings.get_Command_Set_As_Start_State(), new GUILayoutOption[0]))
            {
                EditorCommands.SetSelectedStateAsStartState();
                SkillEditor.RepaintAll();
            }
            if (GUILayout.Button(Strings.get_Command_Toggle_Breakpoint(), new GUILayoutOption[0]))
            {
                EditorCommands.ToggleBreakpointOnSelectedState();
                SkillEditor.RepaintAll();
            }
            ToolWindow.Divider(Strings.get_ToolWindow_Header_Transitions());
            if (GUILayout.Button(Strings.get_Command_Add_Transition(), new GUILayoutOption[0]))
            {
                EditorCommands.AddTransitionToSelectedState();
                SkillEditor.RepaintAll();
            }
            if (GUILayout.Button(Strings.get_Command_Add_Global_Transition(), new GUILayoutOption[0]))
            {
                EditorCommands.AddGlobalTransitionToSelectedState();
                SkillEditor.RepaintAll();
            }
            if (!SkillEditor.Builder.HasGlobalTransition(SkillEditor.SelectedState))
            {
                return;
            }
            ToolWindow.Divider(Strings.get_ToolWindow_Header_Global_Transitions());
            SkillState selectedState = SkillEditor.SelectedState;

            SkillTransition[] globalTransitions = SkillEditor.SelectedFsm.get_GlobalTransitions();
            for (int i = 0; i < globalTransitions.Length; i++)
            {
                SkillTransition fsmTransition = globalTransitions[i];
                if (!(fsmTransition.get_ToState() != selectedState.get_Name()))
                {
                    GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                    if (GUILayout.Button(Labels.GetEventLabel(fsmTransition), EditorStyles.get_popup(), new GUILayoutOption[]
                    {
                        GUILayout.MinWidth(140f)
                    }))
                    {
                        ToolWindow.editingTransition = fsmTransition;
                        SkillEditorGUILayout.GenerateEventSelectionMenu(SkillEditor.SelectedFsm, fsmTransition.get_FsmEvent(), new GenericMenu.MenuFunction2(ToolWindow.SelectGlobalTransitionEvent), new GenericMenu.MenuFunction(SkillEditor.OpenEventManager)).ShowAsContext();
                    }
                    if (SkillEditorGUILayout.DeleteButton())
                    {
                        EditorCommands.DeleteGlobalTransition(fsmTransition);
                        SkillEditor.RepaintAll();
                    }
                    GUILayout.EndHorizontal();
                }
            }
        }
Пример #4
0
        private static void TransitionTools()
        {
            ToolWindow.Header(Strings.get_ToolWindow_Header_Transition_Tools());
            SkillState      selectedState      = SkillEditor.SelectedState;
            SkillTransition selectedTransition = SkillEditor.SelectedTransition;

            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Label(Strings.get_Label_Event(), new GUILayoutOption[]
            {
                GUILayout.MaxWidth(40f)
            });
            if (GUILayout.Button(Labels.GetEventLabel(selectedTransition), EditorStyles.get_popup(), new GUILayoutOption[0]))
            {
                ToolWindow.editingTransition = selectedTransition;
                SkillEditorGUILayout.GenerateEventSelectionMenu(SkillEditor.SelectedFsm, selectedTransition.get_FsmEvent(), new GenericMenu.MenuFunction2(ToolWindow.SelectEvent), new GenericMenu.MenuFunction(SkillEditor.OpenEventManager)).ShowAsContext();
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Label(Strings.get_Label_State(), new GUILayoutOption[]
            {
                GUILayout.MaxWidth(40f)
            });
            if (GUILayout.Button(Labels.GetStateLabel(selectedTransition.get_ToState()), EditorStyles.get_popup(), new GUILayoutOption[0]))
            {
                ToolWindow.editingTransition = selectedTransition;
                SkillEditorGUILayout.GenerateStateSelectionMenu(SkillEditor.SelectedFsm, selectedTransition.get_ToState(), new GenericMenu.MenuFunction2(ToolWindow.SelectToState)).ShowAsContext();
            }
            GUILayout.EndHorizontal();
            if (GUILayout.Button(Strings.get_Command_Delete(), new GUILayoutOption[0]))
            {
                EditorCommands.DeleteTransition(selectedState, selectedTransition);
                SkillEditor.Selection.SelectTransition(null);
                SkillEditor.RepaintAll();
            }
        }