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(); } }
private void FindEventsInGlobalTransitions() { if (this.fsm == null) { return; } SkillTransition[] globalTransitions = this.fsm.get_GlobalTransitions(); for (int i = 0; i < globalTransitions.Length; i++) { SkillTransition fsmTransition = globalTransitions[i]; if (fsmTransition.get_EventName() != string.Empty) { this.GetEventUsageList(fsmTransition.get_EventName()).Add(new SkillInfo { fsm = this.fsm, state = this.fsm.GetState(fsmTransition.get_ToState()), transition = fsmTransition }); } } }
public static List <SkillInfo> FindTransitionsUsingEvent(Skill fsm, string eventName) { List <SkillInfo> list = new List <SkillInfo>(); SkillState[] states = fsm.get_States(); for (int i = 0; i < states.Length; i++) { SkillState fsmState = states[i]; SkillTransition[] transitions = fsmState.get_Transitions(); for (int j = 0; j < transitions.Length; j++) { SkillTransition fsmTransition = transitions[j]; if (fsmTransition.get_EventName() == eventName) { list.Add(new SkillInfo { fsm = fsm, state = fsmState, transition = fsmTransition }); } } } SkillTransition[] globalTransitions = fsm.get_GlobalTransitions(); for (int k = 0; k < globalTransitions.Length; k++) { SkillTransition fsmTransition2 = globalTransitions[k]; if (fsmTransition2.get_EventName() == eventName) { list.Add(new SkillInfo { fsm = fsm, state = fsm.GetState(fsmTransition2.get_ToState()), transition = fsmTransition2 }); } } return(list); }
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); } } } }
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(); } } }