private void DeleteUnusedVariables() { SkillSearch.Update(SkillEditor.SelectedFsm); List <SkillVariable> unusedVariables = SkillSearch.GetUnusedVariables(SkillEditor.SelectedFsm); if (unusedVariables.get_Count() == 0) { EditorUtility.DisplayDialog(Strings.get_Command_Delete_Unused_Variables(), Strings.get_Label_No_unused_variables(), Strings.get_OK()); return; } if (Dialogs.YesNoDialog(Strings.get_Command_Delete_Unused_Variables(), string.Format(Strings.get_Command_Delete_Variables_Are_you_sure(), unusedVariables.get_Count()))) { SkillEditor.RegisterUndo(Strings.get_Menu_Delete_Unused_Variables()); List <SkillVariable> list = new List <SkillVariable>(unusedVariables); using (List <SkillVariable> .Enumerator enumerator = list.GetEnumerator()) { while (enumerator.MoveNext()) { SkillVariable current = enumerator.get_Current(); this.fsmVariablesEditor.DeleteVariable(current, false, false); } } this.Reset(); } }
public void Clear() { List <NamedVariable> list = new List <NamedVariable>(SkillSearch.globalVariablesUsage.get_Keys()); using (List <NamedVariable> .Enumerator enumerator = list.GetEnumerator()) { while (enumerator.MoveNext()) { NamedVariable current = enumerator.get_Current(); List <SkillInfo> globalVariablesUsageList = SkillSearch.GetGlobalVariablesUsageList(current); List <SkillInfo> list2 = new List <SkillInfo>(globalVariablesUsageList); using (List <SkillInfo> .Enumerator enumerator2 = globalVariablesUsageList.GetEnumerator()) { while (enumerator2.MoveNext()) { SkillInfo current2 = enumerator2.get_Current(); if (current2.fsm == this.fsm) { list2.Remove(current2); } } } SkillSearch.globalVariablesUsage.set_Item(current, list2); } } this.eventUsage.Clear(); this.variableUsage.Clear(); this.globalVariablesUsed.Clear(); this.actionUsage.Clear(); }
private void DeleteUnusedEvents() { SkillSearch.Update(SkillEditor.SelectedFsm); List <string> unusedEvents = SkillSearch.GetUnusedEvents(SkillEditor.SelectedFsm); int count = unusedEvents.get_Count(); if (count == 0) { EditorUtility.DisplayDialog(Strings.get_Dialog_Delete_Unused_Events(), Strings.get_Dialog_No_unused_events(), Strings.get_OK()); return; } if (Dialogs.YesNoDialog(Strings.get_Dialog_Delete_Unused_Events(), string.Format(Strings.get_Dialog_Delete_Unused_Events_Are_you_sure(), count))) { SkillEditor.RegisterUndo(Strings.get_Dialog_Delete_Unused_Events()); using (List <string> .Enumerator enumerator = unusedEvents.GetEnumerator()) { while (enumerator.MoveNext()) { string current = enumerator.get_Current(); if (!SkillEvent.IsEventGlobal(current)) { SkillEditor.Builder.DeleteEvent(SkillEditor.SelectedFsm, current); } } } this.Reset(); } SkillEditor.SetFsmDirty(true, false); }
private void ChangeVariableType(SkillVariable fsmVariable, VariableType newType) { if (!this.CheckDeleteVariable(Strings.get_Dialog_Edit_Variable_Type(), Strings.get_Dialog_Edit_Variable_Type_Are_you_sure(), fsmVariable)) { return; } this.RegisterUndo(Strings.get_Label_Edit_Variable()); string name = fsmVariable.Name; string tooltip = fsmVariable.Tooltip; string category = fsmVariable.Category; bool showInInspector = fsmVariable.ShowInInspector; if (this.fsmOwner != null) { SkillBuilder.RemoveVariableUsage(fsmVariable.NamedVar); } else { SkillSearch.UpdateAll(); SkillBuilder.RemoveGlobalVariableUsage(fsmVariable.NamedVar); } SkillVariable.DeleteVariable(this.target, fsmVariable); SkillVariable fsmVariable2 = this.AddVariable(newType, name, false); fsmVariable2.Tooltip = tooltip; fsmVariable2.SetCategory(category); fsmVariable2.ShowInInspector = showInInspector; this.BuildFsmVariableList(true); this.SelectVariable(name); }
private int CompareEventsByUseCount(SkillEvent event1, SkillEvent event2) { if (event1 == null) { if (event2 == null) { return(0); } return(-1); } else { if (event2 == null) { return(1); } int eventUseCount = SkillSearch.GetEventUseCount(SkillEditor.SelectedFsm, event1.get_Name()); int num = SkillSearch.GetEventUseCount(SkillEditor.SelectedFsm, event2.get_Name()).CompareTo(eventUseCount); if (num == 0) { return(string.Compare(event1.get_Name(), event2.get_Name(), 0)); } return(num); } }
public static void SetTransitionTarget(SkillTransition transition, string toState) { SkillEditor.RegisterUndo(Strings.get_Command_Set_Transition_Target()); SkillEditor.Builder.SetTransitionTarget(transition, toState); SkillSearch.Update(SkillEditor.SelectedFsm); SkillEditor.SetFsmDirty(true, false); }
public static void MakeEventGlobal(string eventName) { SkillEvent fsmEvent = SkillEvent.GetFsmEvent(eventName); SkillEditor.Builder.SetEventIsGlobal(SkillEditor.SelectedFsm, fsmEvent, true); SkillSearch.Update(SkillEditor.SelectedFsm); }
public static void Update(Skill fsm) { if (fsm != null) { SkillSearch.GetSearch(fsm).Update(); } SkillEditor.FsmInfoUpdated(fsm); }
public static void DeleteTransition(SkillState state, SkillTransition transition) { SkillEditor.RegisterUndo(Strings.get_Menu_Delete_Transition()); SkillEditor.Builder.DeleteTransition(state, transition); SkillEditor.GraphView.UpdateStateSize(state); SkillSearch.Update(state.get_Fsm()); SkillEditor.SetFsmDirty(state.get_Fsm(), true, false, true); }
public static void SetTransitionEvent(SkillTransition transition, SkillEvent fsmEvent) { SkillEditor.RegisterUndo(Strings.get_Command_Set_Transition_Event()); SkillEditor.Builder.SetTransitionEvent(transition, fsmEvent); SkillEditor.GraphView.UpdateStateSize(SkillEditor.SelectedState); SkillSearch.Update(SkillEditor.SelectedFsm); SkillEditor.SetFsmDirty(true, false); }
private bool CheckDeleteVariable(string title, string warning, SkillVariable fsmVariable) { if (this.globalsOwner != null) { return(Dialogs.YesNoDialog(title, Strings.get_Label_Check_Edit_Global_Variable())); } return(this.fsmOwner == null || SkillSearch.GetUnusedVariables(this.fsmOwner).Contains(fsmVariable) || Dialogs.YesNoDialog(title, warning)); }
public override void DoGUI() { this.fsmVariablesEditor.SetTarget(SkillVariables.get_GlobalsComponent()); this.fsmVariablesEditor.OnGUI(); if (GUILayout.Button(new GUIContent(Strings.get_GlobalVariablesWindow_Refresh_Used_Count_In_This_Scene(), Strings.get_GlobalVariablesWindow_Refresh_Tooltip()), new GUILayoutOption[0])) { SkillSearch.UpdateAll(); } EditorGUILayout.HelpBox(Strings.get_GlobalVariablesWindow_Note_Asset_Location(), 1); }
public static SkillTransition AddGlobalTransition(SkillState state, SkillEvent fsmEvent) { SkillEditor.RegisterUndo(Strings.get_Command_Add_Global_Transition()); SkillTransition result = SkillEditor.Builder.AddGlobalTransition(state, fsmEvent); SkillEditor.GraphView.UpdateStateSize(state); SkillSearch.Update(state.get_Fsm()); SkillEditor.SetFsmDirty(state.get_Fsm(), true, false, true); return(result); }
public static void DeleteGlobalTransition(SkillTransition transition) { SkillEditor.RegisterUndo(Strings.get_Command_Delete_Global_Transition()); SkillState transitionState = SkillBuilder.GetTransitionState(SkillEditor.SelectedFsm, transition); SkillEditor.Builder.DeleteGlobalTransition(transition); SkillSearch.Update(SkillEditor.SelectedFsm); SkillEditor.GraphView.UpdateStateSize(transitionState); SkillEditor.SetFsmDirty(true, false); Keyboard.ResetFocus(); }
public static void AddTransitionToState(SkillState state, string eventName = "") { SkillEditor.RegisterUndo(Strings.get_Command_Add_Transition()); SkillTransition fsmTransition = SkillEditor.Builder.AddTransition(SkillEditor.SelectedState); fsmTransition.set_FsmEvent(SkillEvent.GetFsmEvent(eventName)); SkillEditor.Selection.SelectTransition(fsmTransition); SkillEditor.GraphView.UpdateStateSize(SkillEditor.SelectedState); SkillSearch.Update(SkillEditor.SelectedFsm); SkillEditor.SetFsmDirty(true, false); }
public static void UpdateAll() { SkillSearch.globalVariablesUsage.Clear(); SkillSearch.GlobalVariablesUsageInitialized = true; using (List <Skill> .Enumerator enumerator = SkillEditor.FsmList.GetEnumerator()) { while (enumerator.MoveNext()) { Skill current = enumerator.get_Current(); SkillSearch.Update(current); } } }
private int GetUsedCount(NamedVariable variable) { if (this.fsmOwner != null) { return(SkillSearch.GetVariableUseCount(this.fsmOwner, variable)); } if (!(this.globalsOwner != null)) { return(-1); } if (SkillSearch.GlobalVariablesUsageInitialized) { return(SkillSearch.GetGlobalVariablesUsageCount(variable)); } return(-1); }
public static SkillSearch GetSearch(Skill fsm) { if (SkillSearch.lastFsmSearch != null && fsm == SkillSearch.lastFsmSearch.fsm) { return(SkillSearch.lastFsmSearch); } SkillSearch fsmSearch; SkillSearch.fsmCache.TryGetValue(fsm, ref fsmSearch); if (fsmSearch == null) { fsmSearch = new SkillSearch(fsm); SkillSearch.fsmCache.Add(fsm, fsmSearch); } SkillSearch.lastFsmSearch = fsmSearch; return(fsmSearch); }
private void DoGlobalVariablesTable() { if (SkillSearch.GetGlobalVariablesUsedCount(SkillEditor.SelectedFsm) == 0) { return; } GUILayout.Space(10f); SkillEditorGUILayout.LightDivider(new GUILayoutOption[0]); GUILayout.BeginHorizontal(SkillEditorStyles.TableRowBox, new GUILayoutOption[0]); GUILayout.Label(SkillEditorContent.GlobalsLabel, new GUILayoutOption[0]); GUILayout.FlexibleSpace(); GUILayout.Label(SkillEditorContent.VariableUseCountLabel, new GUILayoutOption[0]); GUILayout.EndHorizontal(); List <NamedVariable> globalVariablesUsed = SkillSearch.GetGlobalVariablesUsed(SkillEditor.SelectedFsm); using (List <NamedVariable> .Enumerator enumerator = globalVariablesUsed.GetEnumerator()) { while (enumerator.MoveNext()) { NamedVariable current = enumerator.get_Current(); GUILayout.BeginHorizontal(SkillEditorStyles.TableRowBox, new GUILayoutOption[0]); GUIStyle tableRowText = SkillEditorStyles.TableRowText; if (GUILayout.Button(new GUIContent(current.get_Name(), current.get_Tooltip()), tableRowText, new GUILayoutOption[] { GUILayout.MinWidth(155f) })) { Keyboard.ResetFocus(); this.Deselect(); if (Event.get_current().get_button() == 1 || EditorGUI.get_actionKey()) { FsmVariablesEditor.DoGlobalVariableContextMenu(current); } } int globalVariablesUsageCount = SkillSearch.GetGlobalVariablesUsageCount(current); GUILayout.FlexibleSpace(); GUILayout.Label(globalVariablesUsageCount.ToString(CultureInfo.get_CurrentCulture()), tableRowText, new GUILayoutOption[0]); GUILayout.Space(10f); GUILayout.EndHorizontal(); if (FsmEditorSettings.DebugVariables) { SkillEditorGUILayout.ReadonlyTextField(current.ToString(), new GUILayoutOption[0]); } } } }
private void DoEventLine(SkillEvent fsmEvent) { int eventUseCount = SkillSearch.GetEventUseCount(SkillEditor.SelectedFsm, fsmEvent.get_Name()); GUILayout.BeginHorizontal((this.selectedEvent != null && fsmEvent.get_Name() == this.selectedEvent.get_Name()) ? SkillEditorStyles.SelectedEventBox : SkillEditorStyles.TableRowBox, new GUILayoutOption[0]); EditorGUI.BeginDisabledGroup(fsmEvent.get_IsSystemEvent()); bool flag = GUILayout.Toggle(fsmEvent.get_IsGlobal(), SkillEditorContent.GlobalEventTooltipLabel, SkillEditorStyles.TableRowCheckBox, new GUILayoutOption[] { GUILayout.MaxWidth(17f), GUILayout.MinWidth(17f) }); if (flag != fsmEvent.get_IsGlobal()) { SkillEditor.Builder.SetEventIsGlobal(SkillEditor.SelectedFsm, fsmEvent, flag); GlobalEventsWindow.ResetView(); } EditorGUI.EndDisabledGroup(); GUIStyle gUIStyle = (this.selectedEvent != null && fsmEvent.get_Name() == this.selectedEvent.get_Name()) ? SkillEditorStyles.TableRowTextSelected : SkillEditorStyles.TableRowText; if (GUILayout.Button(fsmEvent.get_Name(), gUIStyle, new GUILayoutOption[] { GUILayout.MinWidth(244f) })) { this.SelectEvent(fsmEvent, true); GUIUtility.set_keyboardControl(0); if (Event.get_current().get_button() == 1 || EditorGUI.get_actionKey()) { this.GenerateStateListMenu(this.selectedEvent).ShowAsContext(); } } GUILayout.FlexibleSpace(); GUILayout.Label(eventUseCount.ToString(CultureInfo.get_CurrentCulture()), gUIStyle, new GUILayoutOption[0]); GUILayout.Space(5f); if (SkillEditorGUILayout.DeleteButton()) { EditorCommands.DeleteEvent(fsmEvent); this.Reset(); } GUILayout.EndHorizontal(); }
private void AddVariableUsage(NamedVariable variable) { if (variable == null) { return; } if (this.IsGlobalVariable(variable)) { SkillSearch.GetGlobalVariablesUsageList(variable).Add(new SkillInfo(SkillSearch.currentInfo)); if (!this.globalVariablesUsed.Contains(variable)) { this.globalVariablesUsed.Add(variable); return; } } else { this.GetVariableUsageList(variable).Add(new SkillInfo(SkillSearch.currentInfo)); } }
private GenericMenu GenerateStateListMenu(SkillEvent fsmEvent) { GenericMenu genericMenu = new GenericMenu(); if (SkillSearch.GetEventUseCount(SkillEditor.SelectedFsm, fsmEvent.get_Name()) == 0) { genericMenu.AddDisabledItem(new GUIContent(Strings.get_Menu_Unused_Event())); return(genericMenu); } List <SkillState> list = SkillInfo.FindStatesUsingEvent(SkillEditor.SelectedFsm, fsmEvent.get_Name()); using (List <SkillState> .Enumerator enumerator = list.GetEnumerator()) { while (enumerator.MoveNext()) { SkillState current = enumerator.get_Current(); genericMenu.AddItem(new GUIContent(current.get_Name()), SkillEditor.SelectedState == current, new GenericMenu.MenuFunction2(EditorCommands.SelectState), current); } } return(genericMenu); }
private static void DoVariableContextMenu(SkillVariable variable) { GenericMenu genericMenu = new GenericMenu(); List <SkillInfo> globalVariablesUsageList = SkillSearch.GetGlobalVariablesUsageList(variable.NamedVar); if (globalVariablesUsageList.get_Count() == 0) { genericMenu.AddDisabledItem(new GUIContent(Strings.get_Menu_No_FSMs_use_this_variable())); } else { using (List <SkillInfo> .Enumerator enumerator = globalVariablesUsageList.GetEnumerator()) { while (enumerator.MoveNext()) { SkillInfo current = enumerator.get_Current(); genericMenu.AddItem(new GUIContent(Labels.GetFullFsmLabel(current.fsm)), SkillEditor.SelectedFsm == current.fsm, new GenericMenu.MenuFunction2(EditorCommands.SelectFsm), current.fsm); } } } genericMenu.ShowAsContext(); }
private static void DoGlobalVariableContextMenu(NamedVariable variable) { GenericMenu genericMenu = new GenericMenu(); List <SkillInfo> globalVariablesUsageList = SkillSearch.GetGlobalVariablesUsageList(variable); if (globalVariablesUsageList.get_Count() == 0) { genericMenu.AddDisabledItem(new GUIContent(Strings.get_Menu_No_FSMs_use_this_variable())); } else { using (List <SkillInfo> .Enumerator enumerator = globalVariablesUsageList.GetEnumerator()) { while (enumerator.MoveNext()) { SkillInfo current = enumerator.get_Current(); if (current.fsm == SkillEditor.SelectedFsm) { genericMenu.AddItem(new GUIContent(current.state.get_Name()), SkillEditor.SelectedState == current.state, new GenericMenu.MenuFunction2(FsmVariablesEditor.SelectState), current.state); } } } using (List <SkillInfo> .Enumerator enumerator2 = globalVariablesUsageList.GetEnumerator()) { while (enumerator2.MoveNext()) { SkillInfo current2 = enumerator2.get_Current(); if (current2.fsm != SkillEditor.SelectedFsm) { genericMenu.AddItem(new GUIContent(Labels.GetFullFsmLabel(current2.fsm)), SkillEditor.SelectedFsm == current2.fsm, new GenericMenu.MenuFunction2(EditorCommands.SelectFsm), current2.fsm); } } } } genericMenu.AddSeparator(""); genericMenu.AddItem(new GUIContent(Strings.get_Menu_Make_Local_Variable()), false, new GenericMenu.MenuFunction2(FsmVariablesEditor.MoveToLocal), variable); genericMenu.ShowAsContext(); }
private void DoVariableContextMenu(SkillVariable variable) { GenericMenu genericMenu = new GenericMenu(); List <SkillInfo> variableUsageList = SkillSearch.GetVariableUsageList(SkillEditor.SelectedFsm, variable.NamedVar); if (variableUsageList.get_Count() == 0) { genericMenu.AddDisabledItem(new GUIContent(Strings.get_Menu_Unused_Variable())); } else { using (List <SkillInfo> .Enumerator enumerator = variableUsageList.GetEnumerator()) { while (enumerator.MoveNext()) { SkillInfo current = enumerator.get_Current(); genericMenu.AddItem(new GUIContent(current.state.get_Name()), SkillEditor.SelectedState == current.state, new GenericMenu.MenuFunction2(VariableManager.SelectFsmInfo), current); } } } genericMenu.AddSeparator(""); genericMenu.AddItem(new GUIContent(Strings.get_Menu_Move_To_Global_Variables()), false, new GenericMenu.MenuFunction2(this.MoveToGlobals), variable); genericMenu.ShowAsContext(); }
public static List <string> FindVariablesUsedByActions(Skill fsm, IEnumerable <SkillStateAction> actions) { return(SkillSearch.GetSearch(fsm).FindVariablesUsedByActions(actions)); }
public static List <string> FindVariablesUsedByStates(Skill fsm, IEnumerable <SkillState> states) { return(SkillSearch.GetSearch(fsm).FindVariablesUsedByStates(states)); }
public static List <SkillVariable> GetUnusedVariables(Skill fsm) { SkillSearch.Update(fsm); return(SkillSearch.GetSearch(fsm).GetUnusedVariables()); }
public static int GetVariableUseCount(Skill fsm, NamedVariable variable) { return(SkillSearch.GetSearch(fsm).GetVariableUseCount(variable)); }
public static int GetGlobalVariablesUsedCount(Skill fsm) { return(SkillSearch.GetSearch(fsm).globalVariablesUsed.get_Count()); }