private void BuildCustomAction() { this.code = "using UnityEngine;\n\nnamespace HutongGames.PlayMaker.Actions\n{\n\n"; if (string.IsNullOrEmpty(this.customCategory)) { this.code = this.code + "[ActionCategory(ActionCategory." + this.actionCategories[this.selectedCategory] + ")]\n"; } else { this.code = this.code + "[ActionCategory(\"" + this.customCategory + "\")]\n"; } if (!string.IsNullOrEmpty(this.tooltip)) { this.code = this.code + "[Tooltip(\"" + this.tooltip + "\")]\n"; } this.code = this.code + "public class " + this.actionName + " : FsmStateAction\n{\n\n"; if (this.handlesOnEnter) { this.code += CustomActionWizard.BuildOverrideMethod("void OnEnter()", "Code that runs on entering the state.", this.HasUpdateMethod() ? "" : "Finish();"); } if (this.handlesOnUpdate) { this.code += CustomActionWizard.BuildOverrideMethod("void OnUpdate()", "Code that runs every frame.", ""); } if (this.handlesOnFixedUpdate) { this.code += CustomActionWizard.BuildOverrideMethod("void OnFixedUpdate()", "", ""); } if (this.handlesOnLateUpdate) { this.code += CustomActionWizard.BuildOverrideMethod("void OnLateUpdate()", "", ""); } if (this.handlesOnExit) { this.code += CustomActionWizard.BuildOverrideMethod("void OnExit()", "Code that runs when exiting the state.", ""); } if (this.hasCustomErrorChecker) { this.code += CustomActionWizard.BuildOverrideMethod("string ErrorCheck()", "Perform custom error checking here.", "// Return an error string or null if no error.\n\nreturn null;"); } this.code += "\n}\n\n}\n"; }
public override void DoGUI() { SkillEditorStyles.Init(); SkillEditorGUILayout.ToolWindowLargeTitle(this, Strings.get_CustomActionWizard_Full_Title()); SkillEditorGUILayout.LabelWidth(200f); this.HandleDragPreviewDivider(); this.controlsScrollPosition = EditorGUILayout.BeginScrollView(this.controlsScrollPosition, new GUILayoutOption[0]); EditorGUI.set_indentLevel(1); CustomActionWizard.ControlGroup(Strings.get_CustomActionWizard_Group_Name_and_Description()); this.actionName = SkillEditorGUILayout.TextFieldWithHint(this.actionName, Strings.get_CustomActionWizard_Label_Action_Name(), new GUILayoutOption[0]); this.tooltip = SkillEditorGUILayout.TextAreaWithHint(this.tooltip, Strings.get_CustomActionWizard_Label_Description(), new GUILayoutOption[] { GUILayout.Height(80f) }); CustomActionWizard.ControlGroup(Strings.get_CustomActionWizard_Group_Category()); GUI.set_enabled(string.IsNullOrEmpty(this.customCategory)); this.selectedCategory = EditorGUILayout.Popup(Strings.get_CustomActionWizard_Select_Category(), this.selectedCategory, this.actionCategories, new GUILayoutOption[0]); GUI.set_enabled(true); this.customCategory = EditorGUILayout.TextField(Strings.get_CustomActionWizard_Custom_Category(), this.customCategory, new GUILayoutOption[0]); CustomActionWizard.ControlGroup(Strings.get_CustomActionWizard_Generated_Code_Folder()); this.rootFolder = EditorGUILayout.TextField(Strings.get_CustomActionWizard_Root_Folder(), this.rootFolder, new GUILayoutOption[0]); GUI.set_enabled(!this.folderSameAsCategory); this.actionFolder = EditorGUILayout.TextField(Strings.get_CustomActionWizard_Action_Folder(), this.actionFolder, new GUILayoutOption[0]); GUI.set_enabled(true); this.folderSameAsCategory = EditorGUILayout.Toggle(Strings.get_CustomActionWizard_Same_as_Category(), this.folderSameAsCategory, new GUILayoutOption[0]); CustomActionWizard.ControlGroup(Strings.get_CustomActionWizard_Add_Methods()); this.handlesOnEnter = EditorGUILayout.Toggle("OnEnter", this.handlesOnEnter, new GUILayoutOption[0]); this.handlesOnUpdate = EditorGUILayout.Toggle("OnUpdate", this.handlesOnUpdate, new GUILayoutOption[0]); this.handlesOnFixedUpdate = EditorGUILayout.Toggle("OnFixedUpdate", this.handlesOnFixedUpdate, new GUILayoutOption[0]); this.handlesOnLateUpdate = EditorGUILayout.Toggle("OnLateUpdate", this.handlesOnLateUpdate, new GUILayoutOption[0]); this.handlesOnExit = EditorGUILayout.Toggle("OnExit", this.handlesOnExit, new GUILayoutOption[0]); this.hasCustomErrorChecker = EditorGUILayout.Toggle(Strings.get_CustomActionWizard_Custom_Error_Checker(), this.hasCustomErrorChecker, new GUILayoutOption[0]); EditorGUILayout.EndScrollView(); if (!this.isValid) { SkillEditorGUILayout.Divider(new GUILayoutOption[0]); EditorGUI.set_indentLevel(0); EditorGUILayout.HelpBox(this.errorString, 3, true); } GUILayout.BeginHorizontal(EditorStyles.get_toolbar(), new GUILayoutOption[0]); GUILayout.Label(Strings.get_CustomActionWizard_Code_Preview(), new GUILayoutOption[0]); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (Event.get_current().get_type() == 7) { this.previewDividerRect = GUILayoutUtility.GetLastRect(); } EditorGUIUtility.AddCursorRect(this.previewDividerRect, 2); this.previewScrollPosition = EditorGUILayout.BeginScrollView(this.previewScrollPosition, new GUILayoutOption[] { GUILayout.MinHeight(this.previewHeight) }); GUILayout.Label(this.code, new GUILayoutOption[0]); EditorGUILayout.EndScrollView(); SkillEditorGUILayout.Divider(new GUILayoutOption[0]); GUILayout.Label(Strings.get_CustomActionWizard_File_Path_Prefix() + this.localAssetFilename, new GUILayoutOption[0]); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUI.set_enabled(this.isValid); if (GUILayout.Button(Strings.get_CustomActionWizard_Save_Button(), new GUILayoutOption[0])) { this.SaveCustomAction(); GUIUtility.ExitGUI(); return; } GUI.set_enabled(true); if (GUILayout.Button(new GUIContent(Strings.get_CustomActionWizard_Find_File(), Strings.get_CustomActionWizard_Find_File_Tooltip()), new GUILayoutOption[] { GUILayout.MaxWidth(100f) })) { this.PingScriptFile(); } if (GUILayout.Button(new GUIContent(Strings.get_CustomActionWizard_Copy_Code(), Strings.get_CustomActionWizard_Copy_Code_Tooltip()), new GUILayoutOption[] { GUILayout.MaxWidth(100f) })) { this.CopyCodeToClipboard(); } GUILayout.EndHorizontal(); GUILayout.Space(10f); EditorGUI.set_indentLevel(0); if (GUI.get_changed()) { this.UpdateGUI(); GUIUtility.ExitGUI(); } }