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(); } }
private static void AddSetPropertyAction() { Type actionType = ActionData.GetActionType("HutongGames.PlayMaker.Actions.SetProperty"); if (actionType == null) { Dialogs.MissingAction("Set Property"); return; } SkillStateAction fsmStateAction = SkillEditor.Builder.InsertAction(SkillEditorMacros.droppedOnState, actionType, SkillEditorMacros.droppedOnAction); FieldInfo field = actionType.GetField("targetProperty", 20); if (field != null) { FieldInfo arg_6B_0 = field; object arg_6B_1 = fsmStateAction; SkillProperty fsmProperty = new SkillProperty(); SkillProperty arg_5E_0 = fsmProperty; SkillObject fsmObject = new SkillObject(); fsmObject.set_Value(SkillEditorMacros.droppedObject); arg_5E_0.TargetObject = fsmObject; fsmProperty.setProperty = true; arg_6B_0.SetValue(arg_6B_1, fsmProperty); } SkillEditor.SetFsmDirty(SkillEditorMacros.droppedOnFsm, true, false, true); SkillEditor.SaveActions(SkillEditorMacros.droppedOnFsm); }
public void OnGUI() { if (SkillEditor.SelectedFsm == null) { GUILayout.FlexibleSpace(); return; } this.DoTableHeaders(); this.DoEventTable(); if (Event.get_current().get_type() == 16) { this.GenerateEventManagerMenu().ShowAsContext(); } this.DoEventEditor(); EditorGUILayout.Space(); if (GUILayout.Button(SkillEditorContent.EventBrowserButtonLabel, new GUILayoutOption[0])) { SkillEditor.OpenGlobalEventsWindow(); GUIUtility.ExitGUI(); } if (FsmEditorSettings.ShowHints) { GUILayout.Box(Strings.get_Tooltip_Event_Browser_Button_in_Events_Tab(), SkillEditorStyles.HintBox, new GUILayoutOption[0]); } EditorGUILayout.Space(); if (Event.get_current().get_type() == null && GUIUtility.get_keyboardControl() == 0) { this.Reset(); } }
public static void SelectLogEntry(SkillLogEntry logEntry, bool updateTime = true) { if (logEntry != null) { DebugFlow.SelectedLog = logEntry.get_Log(); DebugFlow.SelectedLogEntry = logEntry; DebugFlow.DebugState = logEntry.get_State(); DebugFlow.SelectedLogEntryIndex = logEntry.GetIndex(); if (updateTime) { DebugFlow.CurrentDebugTime = logEntry.get_Time(); DebugFlow.CurrentDebugFrame = logEntry.get_FrameCount(); } SkillEditor.SelectState(logEntry.get_State(), true); if (logEntry.get_Action() != null) { SkillEditor.SelectAction(logEntry.get_Action(), true); } if (FsmEditorSettings.EnableDebugFlow && DebugFlow.SelectedLog.get_Fsm().EnableDebugFlow&& DebugFlow.SelectedLogEntryIndex < DebugFlow.lastEnterIndex) { DebugFlow.RestoreNearestVariables(logEntry); } if (DebugFlow.LogEntrySelected != null) { DebugFlow.LogEntrySelected(logEntry); } SkillEditor.Repaint(true); } }
public void SetMode(InspectorMode mode) { if (this.inspectorMode == mode) { return; } SkillEditor.DoDirtyFsmPrefab(); EditorPrefs.SetInt(EditorPrefStrings.get_InspectorMode(), (int)mode); Keyboard.ResetFocus(); this.inspectorMode = mode; this.ResetView(); InspectorMode inspectorMode = this.inspectorMode; if (inspectorMode != InspectorMode.FsmInspector) { if (inspectorMode == InspectorMode.Watermarks) { WatermarkSelector.Init(); } } else { FsmInspector.Init(); } SkillEditor.Repaint(true); }
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); }
private static void DoCheckForErrors() { FsmErrorChecker.ClearErrors(false); try { using (List <Skill> .Enumerator enumerator = SkillEditor.FsmList.GetEnumerator()) { while (enumerator.MoveNext()) { Skill current = enumerator.get_Current(); FsmErrorChecker.DoCheckFsmForErrors(current); } } using (List <SkillTemplate> .Enumerator enumerator2 = Templates.List.GetEnumerator()) { while (enumerator2.MoveNext()) { SkillTemplate current2 = enumerator2.get_Current(); if (!(current2 == SkillBuilder.Clipboard)) { FsmErrorChecker.DoCheckFsmForErrors(current2.fsm); } } } } catch (Exception ex) { Debug.LogError(ex.ToString()); throw; } SkillEditor.RepaintAll(); }
private static void AddTreeItem() { SkillEditor editor = GetPanel(); foreach (var skill in skillTable.Values) { TreeViewItem skillItem = editor.AddSkill(skillTree.RootItem, skill.ID); for (int i = 0; i < skill.ActiveEvents.Count; i++) { TreeViewItem eventItem = editor.AddEvent(skillItem, skill.ActiveEvents[i].name); for (int j = 0; j < skill.ActiveEvents[i].actions.Count; j++) { editor.AddAction(eventItem, skill.ActiveEvents[i].actions[j].name); } } for (int i = 0; i < skill.AnimEvents.Count; i++) { TreeViewItem eventItem = editor.AddEvent(skillItem, skill.AnimEvents[i].name); for (int j = 0; j < skill.AnimEvents[i].actions.Count; j++) { editor.AddAction(eventItem, skill.AnimEvents[i].actions[j].name); } } } }
private static void AddAction(object userdata) { ActionUtility.ActionCreationParams actionCreationParams = (ActionUtility.ActionCreationParams)userdata; SkillStateAction action = ActionUtility.AddAction(actionCreationParams.state, actionCreationParams.actionType, actionCreationParams.actionTarget, actionCreationParams.parameter, actionCreationParams.beforeAction); SkillEditor.SelectAction(action, true); }
public static SkillStateAction AddPlayAnimationAction(Skill targetFsm, SkillState state, AnimationClip anim, SkillStateAction beforeAction = null) { SkillStateAction fsmStateAction = ActionUtility.AddAction(state, "HutongGames.PlayMaker.Actions.PlayAnimation", beforeAction); if (fsmStateAction == null) { return(null); } if (!ActionUtility.GameObjectHasAnimationClip(targetFsm.get_GameObject(), anim.get_name()) && Dialogs.YesNoDialog(Strings.get_ActionUtility_Add_Animation_Clip_to_GameObject())) { ActionUtility.AddAnimationClip(targetFsm.get_GameObject(), anim); } FieldInfo field = fsmStateAction.GetType().GetField("animName", 20); if (field != null) { FieldInfo arg_68_0 = field; object arg_68_1 = fsmStateAction; SkillString fsmString = new SkillString(); fsmString.set_Value(anim.get_name()); arg_68_0.SetValue(arg_68_1, fsmString); } SkillEditor.SetFsmDirty(targetFsm, true, false, true); SkillEditor.SaveActions(targetFsm); return(fsmStateAction); }
private static void BeginPrefabInstanceCheck() { if (FsmEditorSettings.ConfirmEditingPrefabInstances && InspectorPanel.editingPrefabInstance != null && InspectorPanel.editingPrefabInstance == SkillEditor.SelectedFsm) { EditorGUILayout.HelpBox(Strings.get_Label_Editing_Prefab_Instance(), 1); InspectorPanel.editingDisabledForPrefabInstance = false; } else { InspectorPanel.editingDisabledForPrefabInstance = (FsmEditorSettings.ConfirmEditingPrefabInstances && SkillPrefabs.IsPrefabInstance(SkillEditor.SelectedFsm)); if (InspectorPanel.editingDisabledForPrefabInstance) { EditorGUILayout.HelpBox(Strings.get_Label_Confirm_Editing_of_Prefab_Instance(), 1); GUILayout.BeginHorizontal(new GUILayoutOption[0]); if (GUILayout.Button(Strings.get_Label_Edit_Prefab(), new GUILayoutOption[0])) { SkillEditor.SelectPrefabParent(); } if (GUILayout.Button(Strings.get_Label_Edit_Instance(), new GUILayoutOption[0])) { InspectorPanel.editingPrefabInstance = SkillEditor.SelectedFsm; } GUILayout.EndHorizontal(); SkillEditor.GraphView.DisableEditing(Strings.get_Label_Editing_of_Prefab_Instance_is_disabled()); } } EditorGUI.BeginDisabledGroup(InspectorPanel.editingDisabledForPrefabInstance); }
public void DeselectAll() { Keyboard.ResetFocus(); this.selectedEvent = null; this.newEventName = ""; SkillEditor.Repaint(true); }
private void RenameEvent() { SkillEditor.Builder.RenameEvent(this.selectedEvent.get_Name(), this.newEventName); GlobalEventsWindow.DeselectAll(); SkillEditor.EventManager.DeselectAll(); SkillEditor.RepaintAll(); }
private void DoAutoScroll() { if (this.selectedFsmVariable == null) { return; } if (Event.get_current().get_type() == 7 && this.autoScroll) { this.scrollViewHeight = GUILayoutUtility.GetLastRect().get_height(); if (this.selectedRect.get_y() < 0f) { this.scrollPosition.y = this.scrollPosition.y + this.selectedRect.get_y(); SkillEditor.Repaint(false); } else { if (this.selectedRect.get_y() + this.selectedRect.get_height() > this.scrollViewHeight) { this.scrollPosition.y = this.scrollPosition.y + (this.selectedRect.get_y() + this.selectedRect.get_height() - this.scrollViewHeight); SkillEditor.Repaint(false); } } this.autoScroll = false; } }
private static void SelectEvent(object userdata) { SkillEvent fsmEvent = userdata as SkillEvent; EditorCommands.SetTransitionEvent(ToolWindow.editingTransition, fsmEvent); SkillEditor.RepaintAll(); }
private static void SelectToState(object userdata) { string toState = userdata as string; EditorCommands.SetTransitionTarget(ToolWindow.editingTransition, toState); SkillEditor.RepaintAll(); }
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 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); }
public static void SanityCheckEventList(Skill fsm) { bool flag = false; List <SkillEvent> list = new List <SkillEvent>(); SkillEvent[] events = fsm.get_Events(); for (int i = 0; i < events.Length; i++) { SkillEvent fsmEvent = events[i]; if (!SkillEvent.EventListContainsEvent(list, fsmEvent.get_Name())) { list.Add(fsmEvent); } else { flag = true; Debug.LogError(string.Format(Strings.get_Error_Duplicate_Event_Found__(), fsmEvent.get_Name())); } } if (flag) { fsm.set_Events(list.ToArray()); SkillEditor.SetFsmDirty(fsm, false, false, true); } }
private static void SelectWatermark(int index) { string[] names = Watermarks.GetNames(); Watermarks.Set(SkillEditor.SelectedFsm, names[index]); SkillEditor.SetFsmDirty(false, false); WatermarkSelector.selectedWatermarkIndex = index; }
private static void DoDebugControls() { int num = FsmErrorChecker.CountAllErrors(); string text = Strings.get_DebugToolbar_No_errors(); if (num > 0) { text = string.Format("{0} {1}", num, (num > 1) ? Strings.get_DebugToolbar_Label_Errors() : Strings.get_DebugToolbar_Label_Error()); } SkillEditorContent.DebugToolbarErrorCount.set_text(text); if (GUILayout.Button(SkillEditorContent.DebugToolbarErrorCount, SkillEditorStyles.ErrorCount, new GUILayoutOption[0])) { SkillEditor.OpenErrorWindow(); GUIUtility.ExitGUI(); } if (Event.get_current().get_type() == 7) { Rect lastRect = GUILayoutUtility.GetLastRect(); lastRect.set_x(lastRect.get_x() + 4f); lastRect.set_y(lastRect.get_y() + 2f); float width; lastRect.set_height(width = 14f); lastRect.set_width(width); GUIHelpers.DrawTexture(lastRect, (num > 0) ? SkillEditorStyles.Errors : SkillEditorStyles.NoErrors, Color.get_white(), 0); } GUILayout.Space(10f); if (GUILayout.Button(SkillEditorContent.DebugToolbarDebug, EditorStyles.get_toolbarDropDown(), new GUILayoutOption[0])) { DebugToolbar.DoDebugMenu(); } }
public static SkillEditor GetPanel() { if (null == m_instance) { m_instance = EditorWindow.GetWindow <SkillEditor>(false, "技能编辑器", false); } return(m_instance); }
public static void Update(Skill fsm) { if (fsm != null) { SkillSearch.GetSearch(fsm).Update(); } SkillEditor.FsmInfoUpdated(fsm); }
public static NamedVariable AddVariable(VariableType type, string name) { SkillEditor.RegisterUndo(Strings.get_Command_Add_Variable()); NamedVariable result = SkillEditor.Builder.AddVariable(type, name); SkillEditor.SetFsmDirty(true, false); return(result); }
static void Init() { SkillEditor window = (SkillEditor)EditorWindow.GetWindow(typeof(SkillEditor)); window.Show(); window._skillInfo.id = int.Parse(window.GetPlayerPrefs(KEY_SKILL_ID)); window.LoadSkillInfo(); }
public void Reset() { this.DeselectAll(); this.UpdateEventList(); SkillEditor.Repaint(true); SkillEditor.RepaintAll(); GlobalEventsWindow.ResetView(); }
public static SkillEvent AddEvent(string eventName) { SkillEditor.RegisterUndo(Strings.get_Command_Add_Event()); SkillEvent result = SkillEditor.Builder.AddEvent(eventName); SkillEditor.SetFsmDirty(true, false); return(result); }
public static void DeleteEvent(SkillEvent fsmEvent) { SkillEditor.RegisterUndo(Strings.get_Command_Delete_Event()); SkillEditor.Builder.DeleteEvent(fsmEvent); SkillEditor.GraphView.UpdateStateSizes(SkillEditor.SelectedFsm); SkillEditor.SaveActions(SkillEditor.SelectedFsm); Keyboard.ResetFocus(); }
static void window() { //创建窗口 Rect wr = new Rect(0, 0, 500, 500); SkillEditor window = (SkillEditor)EditorWindow.GetWindow(typeof(SkillEditor)); window.Show(); }
private void RemoveLocalVariable(SkillVariable variable) { SkillVariable.DeleteVariable(SkillEditor.SelectedFsm.get_Variables(), variable); SkillEditor.SelectedFsm.Reinitialize(); SkillEditor.SetFsmDirty(); this.Reset(); GlobalVariablesWindow.ResetView(); }
public static SkillEditor GetPanel() { if (window == null) { window = EditorWindow.GetWindow<SkillEditor>(false, "Skill Editor", true); } return window; }