public void ShowGUI() { EditorGUILayout.BeginVertical(CustomStyles.thinBox); showEditing = CustomGUILayout.ToggleHeader(showEditing, "ActionList editing settings"); if (showEditing) { displayActionsInInspector = CustomGUILayout.ToggleLeft("List Actions in Inspector window?", displayActionsInInspector, "AC.KickStarter.actionsManager.displayActionsInInspector"); displayActionsInEditor = (DisplayActionsInEditor)CustomGUILayout.EnumPopup("Actions in Editor are:", displayActionsInEditor, "AC.KickStarter.actionsManager.displayActionsInEditor"); actionListEditorScrollWheel = (ActionListEditorScrollWheel)CustomGUILayout.EnumPopup("Using scroll-wheel:", actionListEditorScrollWheel, "AC.KickStarter.actionsManager.actionListEditorScrollWheel"); if (actionListEditorScrollWheel == ActionListEditorScrollWheel.ZoomsWindow) { EditorGUILayout.HelpBox("Panning is possible by holding down the middle-mouse button.", MessageType.Info); } panSpeed = CustomGUILayout.FloatField((actionListEditorScrollWheel == ActionListEditorScrollWheel.PansWindow) ? "Panning speed:" : "Zoom speed:", panSpeed, "AC.KickStarter.actionsManager.panSpeed"); invertPanning = CustomGUILayout.ToggleLeft("Invert panning in ActionList Editor?", invertPanning, "AC.KickStarter.actionsManager.invertPanning"); allowMultipleActionListWindows = CustomGUILayout.ToggleLeft("Allow multiple ActionList Editor windows?", allowMultipleActionListWindows, "AC.KickStarter.actionsManager.allowMultipleActionListWindows"); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.BeginVertical(CustomStyles.thinBox); showCustom = CustomGUILayout.ToggleHeader(showCustom, "Custom Action scripts"); if (showCustom) { GUILayout.BeginHorizontal(); GUILayout.Label("Folder to search:", GUILayout.Width(110f)); GUILayout.Label(customFolderPath, EditorStyles.textField); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Set directory", EditorStyles.miniButtonLeft)) { string path = EditorUtility.OpenFolderPanel("Set custom Actions directory", "Assets", ""); string dataPath = Application.dataPath; if (path.Contains(dataPath)) { if (path == dataPath) { customFolderPath = ""; } else { customFolderPath = path.Replace(dataPath + "/", ""); } } else { ACDebug.LogError("Cannot set new directory - be sure to select within the Assets directory."); } } if (GUILayout.Button("Clear", EditorStyles.miniButtonRight)) { customFolderPath = ""; } GUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); if (AllActions.Count > 0) { GUILayout.Space(10); Upgrade(); EditorGUILayout.BeginVertical(CustomStyles.thinBox); showCategories = CustomGUILayout.ToggleHeader(showCategories, "Action categories"); if (showCategories) { ActionCategory[] categories = (ActionCategory[])System.Enum.GetValues(typeof(ActionCategory)); for (int i = 0; i < categories.Length; i++) { toggles[i] = GUILayout.Toggle(toggles[i], categories[i].ToString(), "Button"); if (toggles[i]) { int j = -1; foreach (ActionType subclass in AllActions) { if (subclass.category == categories[i]) { j++; int enabledIndex = -1; if (EnabledActions.Contains(subclass)) { enabledIndex = EnabledActions.IndexOf(subclass); } if (selectedClass != null && subclass.category == selectedClass.category && subclass.title == selectedClass.title) { EditorGUILayout.BeginVertical("Button"); SpeechLine.ShowField("Name:", subclass.GetFullTitle(), false); SpeechLine.ShowField("Filename:", subclass.fileName + ".cs", false); SpeechLine.ShowField("Description:", subclass.description, true); subclass.isEnabled = true; EditorGUILayout.BeginHorizontal(); if (enabledIndex >= 0) { if (!string.IsNullOrEmpty(defaultClassName) && subclass.fileName == defaultClassName) { EditorGUILayout.LabelField("DEFAULT", CustomStyles.subHeader, GUILayout.Width(140f)); } else if (subclass.isEnabled) { if (GUILayout.Button("Make default?", GUILayout.Width(140f))) { if (EnabledActions.Contains(subclass)) { defaultClassName = subclass.fileName; } } } } subclass.color = EditorGUILayout.ColorField("Node colour:", subclass.color); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Search local instances")) { SearchForInstances(true, subclass); } if (GUILayout.Button("Search all instances")) { if (UnityVersionHandler.SaveSceneIfUserWants()) { SearchForInstances(false, subclass); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } else { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(j.ToString() + ": " + subclass.GetFullTitle(), EditorStyles.label, GUILayout.Width(200f))) { selectedClass = subclass; } if (!string.IsNullOrEmpty(defaultClassName) && subclass.fileName == defaultClassName) { EditorGUILayout.LabelField("DEFAULT", CustomStyles.subHeader, GUILayout.Width(60f)); } EditorGUILayout.EndHorizontal(); GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); } } } if (j < 0) { EditorGUILayout.HelpBox("There are no Actions of this category type present!", MessageType.Info); } } } } EditorGUILayout.EndVertical(); if (defaultClass > EnabledActions.Count - 1) { defaultClass = EnabledActions.Count - 1; } } else { EditorGUILayout.HelpBox("No Action subclass files found.", MessageType.Warning); } if (GUI.changed) { SetEnabled(); Upgrade(); EditorUtility.SetDirty(this); } }
public void ShowGUI() { EditorGUILayout.BeginVertical ("Button"); GUILayout.Label ("Actionlist editing settings", EditorStyles.boldLabel); displayActionsInInspector = EditorGUILayout.ToggleLeft ("List Actions in Inspector window?", displayActionsInInspector); displayActionsInEditor = (DisplayActionsInEditor) EditorGUILayout.EnumPopup ("Actions in Editor are:", displayActionsInEditor); actionListEditorScrollWheel = (ActionListEditorScrollWheel) EditorGUILayout.EnumPopup ("Using scroll-wheel:", actionListEditorScrollWheel); invertPanning = EditorGUILayout.ToggleLeft ("Invert panning in ActionList Editor?", invertPanning); allowMultipleActionListWindows = EditorGUILayout.ToggleLeft ("Allow multiple ActionList Editor windows?", allowMultipleActionListWindows); EditorGUILayout.EndVertical (); EditorGUILayout.Space (); EditorGUILayout.BeginVertical ("Button"); GUILayout.Label ("Custom Action scripts", EditorStyles.boldLabel); GUILayout.BeginHorizontal (); GUILayout.Label ("Folder to search:", GUILayout.Width (110f)); GUILayout.Label (customFolderPath, EditorStyles.textField); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); if (GUILayout.Button ("Set directory")) { string path = EditorUtility.OpenFolderPanel("Set custom Actions directory", "Assets", ""); string dataPath = Application.dataPath; if (path.Contains (dataPath)) { if (path == dataPath) { customFolderPath = ""; } else { customFolderPath = path.Replace (dataPath + "/", ""); } } else { ACDebug.LogError ("Cannot set new directory - be sure to select within the Assets directory."); } } GUILayout.EndHorizontal (); EditorGUILayout.EndVertical (); if (AllActions.Count > 0) { GUILayout.Space (10); foreach (ActionType subclass in AllActions) { int enabledIndex = -1; if (EnabledActions.Contains (subclass)) { enabledIndex = EnabledActions.IndexOf (subclass); } if (selectedClass != null && subclass.category == selectedClass.category && subclass.title == selectedClass.title) { EditorGUILayout.BeginVertical ("Button"); SpeechLine.ShowField ("Name:", subclass.GetFullTitle (), false); SpeechLine.ShowField ("Filename:", subclass.fileName, false); SpeechLine.ShowField ("Description:", subclass.description, true); subclass.isEnabled = true; // This is being set OnEnable anyway, because Action Types are now refreshed/generated automatically, so can't disable //subclass.isEnabled = EditorGUILayout.Toggle ("Is enabled?", subclass.isEnabled); EditorGUILayout.BeginHorizontal (); if (enabledIndex >= 0) { if (enabledIndex == defaultClass) { EditorGUILayout.LabelField ("DEFAULT", EditorStyles.boldLabel, GUILayout.Width (140f)); } else if (subclass.isEnabled) { if (GUILayout.Button ("Make default?", GUILayout.Width (140f))) { if (EnabledActions.Contains (subclass)) { defaultClass = EnabledActions.IndexOf (subclass); } } } } subclass.color = EditorGUILayout.ColorField ("Node colour:", subclass.color); EditorGUILayout.EndHorizontal (); EditorGUILayout.BeginHorizontal (); if (GUILayout.Button ("Search local instances")) { SearchForInstances (true, subclass); } if (GUILayout.Button ("Search all instances")) { SearchForInstances (false, subclass); } EditorGUILayout.EndHorizontal (); EditorGUILayout.EndVertical (); } else { EditorGUILayout.BeginHorizontal (); if (GUILayout.Button (subclass.GetFullTitle (), EditorStyles.label, GUILayout.Width (200f))) { selectedClass = subclass; } if (enabledIndex >= 0 && enabledIndex == defaultClass) { EditorGUILayout.LabelField ("DEFAULT", EditorStyles.boldLabel, GUILayout.Width (60f)); } EditorGUILayout.EndHorizontal (); GUILayout.Box ("", GUILayout.ExpandWidth (true), GUILayout.Height(1)); } } if (defaultClass > EnabledActions.Count - 1) { defaultClass = EnabledActions.Count - 1; } } else { EditorGUILayout.HelpBox ("No Action subclass files found.", MessageType.Warning); } if (GUI.changed) { SetEnabled (); EditorUtility.SetDirty (this); } }
public void ShowGUI() { EditorGUILayout.BeginVertical("Button"); GUILayout.Label("Actionlist editing settings", EditorStyles.boldLabel); displayActionsInInspector = EditorGUILayout.ToggleLeft("List Actions in Inspector window?", displayActionsInInspector); displayActionsInEditor = (DisplayActionsInEditor)EditorGUILayout.EnumPopup("Actions in Editor are:", displayActionsInEditor); actionListEditorScrollWheel = (ActionListEditorScrollWheel)EditorGUILayout.EnumPopup("Using scroll-wheel:", actionListEditorScrollWheel); invertPanning = EditorGUILayout.ToggleLeft("Invert panning in ActionList Editor?", invertPanning); allowMultipleActionListWindows = EditorGUILayout.ToggleLeft("Allow multiple ActionList Editor windows?", allowMultipleActionListWindows); EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.BeginVertical("Button"); GUILayout.Label("Custom Action scripts", EditorStyles.boldLabel); GUILayout.BeginHorizontal(); GUILayout.Label("Folder to search:", GUILayout.Width(110f)); GUILayout.Label(customFolderPath, EditorStyles.textField); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Set directory")) { string path = EditorUtility.OpenFolderPanel("Set custom Actions directory", "Assets", ""); string dataPath = Application.dataPath; if (path.Contains(dataPath)) { if (path == dataPath) { customFolderPath = ""; } else { customFolderPath = path.Replace(dataPath + "/", ""); } } else { Debug.LogError("Cannot set new directory - be sure to select within the Assets directory."); } } GUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); if (AllActions.Count > 0) { GUILayout.Space(10); foreach (ActionType subclass in AllActions) { int enabledIndex = -1; if (EnabledActions.Contains(subclass)) { enabledIndex = EnabledActions.IndexOf(subclass); } if (selectedClass != null && subclass.category == selectedClass.category && subclass.title == selectedClass.title) { EditorGUILayout.BeginVertical("Button"); SpeechLine.ShowField("Name:", subclass.GetFullTitle(), false); SpeechLine.ShowField("Filename:", subclass.fileName, false); SpeechLine.ShowField("Description:", subclass.description, true); subclass.isEnabled = true; // This is being set OnEnable anyway, because Action Types are now refreshed/generated automatically, so can't disable //subclass.isEnabled = EditorGUILayout.Toggle ("Is enabled?", subclass.isEnabled); EditorGUILayout.BeginHorizontal(); if (enabledIndex >= 0) { if (enabledIndex == defaultClass) { EditorGUILayout.LabelField("DEFAULT", EditorStyles.boldLabel, GUILayout.Width(70f)); } else if (subclass.isEnabled) { if (GUILayout.Button("Make default?")) { if (EnabledActions.Contains(subclass)) { defaultClass = EnabledActions.IndexOf(subclass); } } } } if (GUILayout.Button("Search local instances")) { SearchForInstances(true, subclass); } if (GUILayout.Button("Search all instances")) { SearchForInstances(false, subclass); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } else { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(subclass.GetFullTitle(), EditorStyles.label, GUILayout.Width(200f))) { selectedClass = subclass; } if (enabledIndex >= 0 && enabledIndex == defaultClass) { EditorGUILayout.LabelField("DEFAULT", EditorStyles.boldLabel, GUILayout.Width(60f)); } EditorGUILayout.EndHorizontal(); GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); } } if (defaultClass > EnabledActions.Count - 1) { defaultClass = EnabledActions.Count - 1; } } else { EditorGUILayout.HelpBox("No Action subclass files found.", MessageType.Warning); } if (GUI.changed) { SetEnabled(); EditorUtility.SetDirty(this); } }
public void ShowGUI() { EditorGUILayout.BeginVertical ("Button"); GUILayout.Label ("Actionlist editing settings", EditorStyles.boldLabel); displayActionsInInspector = EditorGUILayout.ToggleLeft ("List Actions in Inspector window?", displayActionsInInspector); displayActionsInEditor = (DisplayActionsInEditor) EditorGUILayout.EnumPopup ("Actions in Editor are:", displayActionsInEditor); actionListEditorScrollWheel = (ActionListEditorScrollWheel) EditorGUILayout.EnumPopup ("Using scroll-wheel:", actionListEditorScrollWheel); panSpeed = EditorGUILayout.FloatField ((actionListEditorScrollWheel == ActionListEditorScrollWheel.PansWindow) ? "Panning speed:" : "Zoom speed:", panSpeed); invertPanning = EditorGUILayout.ToggleLeft ("Invert panning in ActionList Editor?", invertPanning); allowMultipleActionListWindows = EditorGUILayout.ToggleLeft ("Allow multiple ActionList Editor windows?", allowMultipleActionListWindows); EditorGUILayout.EndVertical (); EditorGUILayout.Space (); EditorGUILayout.BeginVertical ("Button"); GUILayout.Label ("Custom Action scripts", EditorStyles.boldLabel); GUILayout.BeginHorizontal (); GUILayout.Label ("Folder to search:", GUILayout.Width (110f)); GUILayout.Label (customFolderPath, EditorStyles.textField); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); if (GUILayout.Button ("Set directory")) { string path = EditorUtility.OpenFolderPanel("Set custom Actions directory", "Assets", ""); string dataPath = Application.dataPath; if (path.Contains (dataPath)) { if (path == dataPath) { customFolderPath = ""; } else { customFolderPath = path.Replace (dataPath + "/", ""); } } else { ACDebug.LogError ("Cannot set new directory - be sure to select within the Assets directory."); } } GUILayout.EndHorizontal (); EditorGUILayout.EndVertical (); if (AllActions.Count > 0) { GUILayout.Space (10); EditorGUILayout.BeginVertical ("Button"); EditorGUILayout.LabelField ("Action categories", EditorStyles.boldLabel); ActionCategory[] categories = (ActionCategory[]) System.Enum.GetValues (typeof(ActionCategory)); for (int i=0; i<categories.Length; i++) { toggles[i] = GUILayout.Toggle (toggles[i], categories[i].ToString (), "Button"); if (toggles[i]) { int j=-1; foreach (ActionType subclass in AllActions) { if (subclass.category == categories[i]) { j++; int enabledIndex = -1; if (EnabledActions.Contains (subclass)) { enabledIndex = EnabledActions.IndexOf (subclass); } if (selectedClass != null && subclass.category == selectedClass.category && subclass.title == selectedClass.title) { EditorGUILayout.BeginVertical ("Button"); SpeechLine.ShowField ("Name:", subclass.GetFullTitle (), false); SpeechLine.ShowField ("Filename:", subclass.fileName, false); SpeechLine.ShowField ("Description:", subclass.description, true); subclass.isEnabled = true; EditorGUILayout.BeginHorizontal (); if (enabledIndex >= 0) { if (enabledIndex == defaultClass) { EditorGUILayout.LabelField ("DEFAULT", EditorStyles.boldLabel, GUILayout.Width (140f)); } else if (subclass.isEnabled) { if (GUILayout.Button ("Make default?", GUILayout.Width (140f))) { if (EnabledActions.Contains (subclass)) { defaultClass = EnabledActions.IndexOf (subclass); } } } } subclass.color = EditorGUILayout.ColorField ("Node colour:", subclass.color); EditorGUILayout.EndHorizontal (); EditorGUILayout.BeginHorizontal (); if (GUILayout.Button ("Search local instances")) { SearchForInstances (true, subclass); } if (GUILayout.Button ("Search all instances")) { if (UnityVersionHandler.SaveSceneIfUserWants ()) { SearchForInstances (false, subclass); } } EditorGUILayout.EndHorizontal (); EditorGUILayout.EndVertical (); } else { EditorGUILayout.BeginHorizontal (); if (GUILayout.Button (j.ToString () + ": " + subclass.GetFullTitle (), EditorStyles.label, GUILayout.Width (200f))) { selectedClass = subclass; } if (enabledIndex >= 0 && enabledIndex == defaultClass) { EditorGUILayout.LabelField ("DEFAULT", EditorStyles.boldLabel, GUILayout.Width (60f)); } EditorGUILayout.EndHorizontal (); GUILayout.Box ("", GUILayout.ExpandWidth (true), GUILayout.Height(1)); } } } if (j < 0) { EditorGUILayout.HelpBox ("There are no Actions of this category type present!", MessageType.Info); } } } EditorGUILayout.EndVertical (); if (defaultClass > EnabledActions.Count - 1) { defaultClass = EnabledActions.Count - 1; } } else { EditorGUILayout.HelpBox ("No Action subclass files found.", MessageType.Warning); } if (GUI.changed) { SetEnabled (); EditorUtility.SetDirty (this); } }