public void ShowGUI() { if (icon == null) { icon = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/AdventureCreator/Graphics/Textures/inspector-use.png", typeof(Texture2D)); } EditorGUILayout.BeginVertical("Button"); drawInEditor = EditorGUILayout.Toggle("Test in Game Window?", drawInEditor); drawOutlines = EditorGUILayout.Toggle("Draw outlines?", drawOutlines); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Pause background texture:", GUILayout.Width(255f)); pauseTexture = (Texture2D)EditorGUILayout.ObjectField(pauseTexture, typeof(Texture2D), false, GUILayout.Width(70f), GUILayout.Height(30f)); EditorGUILayout.EndHorizontal(); scaleTextEffects = EditorGUILayout.Toggle("Scale text effects?", scaleTextEffects); globalDepth = EditorGUILayout.IntField("GUI depth:", globalDepth); eventSystem = (UnityEngine.EventSystems.EventSystem)EditorGUILayout.ObjectField("Event system prefab:", eventSystem, typeof(UnityEngine.EventSystems.EventSystem), false); if (drawInEditor && KickStarter.menuPreview == null) { EditorGUILayout.HelpBox("A GameEngine prefab is required to display menus while editing - please click Organise Room Objects within the Scene Manager.", MessageType.Warning); } else if (Application.isPlaying) { EditorGUILayout.HelpBox("Changes made to the menus will not be registed by the game until the game is restarted.", MessageType.Info); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Menus", EditorStyles.boldLabel); CreateMenusGUI(); if (selectedMenu != null) { EditorGUILayout.Space(); string menuTitle = selectedMenu.title; if (menuTitle == "") { menuTitle = "(Untitled)"; } EditorGUILayout.LabelField("Menu " + selectedMenu.id + ": '" + menuTitle + "' properties", EditorStyles.boldLabel); EditorGUILayout.BeginVertical("Button"); selectedMenu.ShowGUI(); EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Menu " + selectedMenu.id + ": '" + menuTitle + "' elements", EditorStyles.boldLabel); EditorGUILayout.BeginVertical("Button"); CreateElementsGUI(selectedMenu); EditorGUILayout.EndVertical(); if (selectedMenuElement != null) { EditorGUILayout.Space(); string elementName = selectedMenuElement.title; if (elementName == "") { elementName = "(Untitled)"; } string elementType = ""; foreach (string _elementType in elementTypes) { if (selectedMenuElement.GetType().ToString().Contains(_elementType)) { elementType = _elementType; break; } } EditorGUILayout.LabelField(elementType + " " + selectedMenuElement.ID + ": '" + elementName + "' properties", EditorStyles.boldLabel); oldVisibility = selectedMenuElement.isVisible; selectedMenuElement.ShowGUIStart(selectedMenu.menuSource); if (selectedMenuElement.isVisible != oldVisibility) { if (!Application.isPlaying) { selectedMenu.Recalculate(); } } } } if (GUI.changed) { if (!Application.isPlaying) { SaveAllMenus(); } EditorUtility.SetDirty(this); } }
/** * Shows the GUI. */ public void ShowGUI() { EditorGUILayout.BeginVertical(CustomStyles.thinBox); drawInEditor = EditorGUILayout.Toggle("Test in Game Window?", drawInEditor); drawOutlines = EditorGUILayout.Toggle("Draw outlines?", drawOutlines); if (drawOutlines && Application.platform == RuntimePlatform.WindowsEditor) { doWindowsPreviewFix = EditorGUILayout.Toggle("Apply outline offset fix?", doWindowsPreviewFix); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Pause background texture:", GUILayout.Width(255f)); pauseTexture = (Texture2D)CustomGUILayout.ObjectField <Texture2D> (pauseTexture, false, GUILayout.Width(70f), GUILayout.Height(30f), "AC.Kickstarter.menuManager.pauseTexture"); EditorGUILayout.EndHorizontal(); scaleTextEffects = CustomGUILayout.Toggle("Scale text effects?", scaleTextEffects, "AC.KickStarter.menuManager.scaleTextEffects"); globalDepth = CustomGUILayout.IntField("GUI depth:", globalDepth, "AC.KickStarter.menuManager.globalDepth"); eventSystem = (UnityEngine.EventSystems.EventSystem)CustomGUILayout.ObjectField <UnityEngine.EventSystems.EventSystem> ("Event system prefab:", eventSystem, false, "AC.KickStarter.menuManager.eventSystem"); if (AdvGame.GetReferences().settingsManager != null && AdvGame.GetReferences().settingsManager.inputMethod == InputMethod.KeyboardOrController) { EditorGUILayout.Space(); keyboardControlWhenPaused = CustomGUILayout.ToggleLeft("Directly-navigate Menus when paused?", keyboardControlWhenPaused, "AC.KickStarter.menuManager.keyboardControlWhenPaused"); keyboardControlWhenDialogOptions = CustomGUILayout.ToggleLeft("Directly-navigate Menus during Conversations?", keyboardControlWhenDialogOptions, "AC.KickStarter.menuManager.keyboardControlWhenDialogOptions"); } if (drawInEditor && KickStarter.menuPreview == null) { EditorGUILayout.HelpBox("A GameEngine prefab is required to display menus while editing - please click Organise Room Objects within the Scene Manager.", MessageType.Warning); } else if (Application.isPlaying) { EditorGUILayout.HelpBox("Changes made to the menus will not be registed by the game until the game is restarted.", MessageType.Info); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); CreateMenusGUI(); if (selectedMenu != null) { EditorGUILayout.Space(); string menuTitle = selectedMenu.title; if (menuTitle == "") { menuTitle = "(Untitled)"; } EditorGUILayout.BeginVertical(CustomStyles.thinBox); EditorGUILayout.LabelField("Menu " + selectedMenu.id + ": '" + menuTitle + "' properties", CustomStyles.subHeader); EditorGUILayout.Space(); selectedMenu.ShowGUI(); EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.BeginVertical(CustomStyles.thinBox); EditorGUILayout.LabelField("Menu " + selectedMenu.id + ": '" + menuTitle + "' elements", CustomStyles.subHeader); EditorGUILayout.Space(); CreateElementsGUI(selectedMenu); EditorGUILayout.EndVertical(); if (selectedMenuElement != null) { EditorGUILayout.Space(); string elementName = selectedMenuElement.title; if (elementName == "") { elementName = "(Untitled)"; } string elementType = ""; foreach (string _elementType in elementTypes) { if (selectedMenuElement.GetType().ToString().Contains(_elementType)) { elementType = _elementType; break; } } EditorGUILayout.BeginVertical(CustomStyles.thinBox); EditorGUILayout.LabelField(elementType + " " + selectedMenuElement.ID + ": '" + elementName + "' properties", CustomStyles.subHeader); oldVisibility = selectedMenuElement.isVisible; selectedMenuElement.ShowGUIStart(selectedMenu); if (selectedMenuElement.isVisible != oldVisibility) { if (!Application.isPlaying) { selectedMenu.Recalculate(); } } } } if (GUI.changed) { if (!Application.isPlaying) { SaveAllMenus(); } EditorUtility.SetDirty(this); } }
/** * Shows the GUI. */ public void ShowGUI() { EditorGUILayout.BeginVertical(CustomStyles.thinBox); Upgrade(); showSettings = CustomGUILayout.ToggleHeader(showSettings, "Global menu settings"); if (showSettings) { drawInEditor = CustomGUILayout.Toggle("Preview in Game window?", drawInEditor, "", "If True, Adventure Creator-sourced menus will be displayed in the Game window in Edit mode so long as a GameEngine prefab is present in the scene."); if (drawInEditor) { drawOutlines = CustomGUILayout.Toggle("Draw outlines?", drawOutlines, "", "If True, yellow outlines will be drawn around Adventure Creator-sourced menus and elements when previewing"); if (drawOutlines && Application.platform == RuntimePlatform.WindowsEditor) { doWindowsPreviewFix = CustomGUILayout.Toggle("Apply outline offset fix?", doWindowsPreviewFix, "", "In some versions of Windows, preview outlines can appear offset. Checking this box should fix this."); } } scaleTextEffects = CustomGUILayout.Toggle("Scale text effects?", scaleTextEffects, "AC.KickStarter.menuManager.scaleTextEffects", "If True, then the size of text effects (shadows, outlines) will be based on the size of the text, rather than fixed"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent("Pause background texture:", "A texture to apply full-screen when a 'Pause' Menu is enabled"), GUILayout.Width(255f)); pauseTexture = (Texture2D)CustomGUILayout.ObjectField <Texture2D> (pauseTexture, false, GUILayout.Width(70f), GUILayout.Height(30f), "AC.Kickstarter.menuManager.pauseTexture"); EditorGUILayout.EndHorizontal(); globalDepth = CustomGUILayout.IntField("GUI depth:", globalDepth, "AC.KickStarter.menuManager.globalDepth", "The depth at which to draw OnGUI-based (Adventure Creator) menus"); eventSystem = (UnityEngine.EventSystems.EventSystem)CustomGUILayout.ObjectField <UnityEngine.EventSystems.EventSystem> ("Event system prefab:", eventSystem, false, "AC.KickStarter.menuManager.eventSystem", "The EventSystem to instantiate when Unity UI-based Menus are used. If none is set, a default one will be used"); if (AdvGame.GetReferences().settingsManager != null && AdvGame.GetReferences().settingsManager.inputMethod != InputMethod.TouchScreen) { EditorGUILayout.Space(); keyboardControlWhenPaused = CustomGUILayout.ToggleLeft("Directly-navigate Menus when paused?", keyboardControlWhenPaused, "AC.KickStarter.menuManager.keyboardControlWhenPaused", "If True, then Menus will be navigated directly, not with the cursor, when the game is paused"); keyboardControlWhenDialogOptions = CustomGUILayout.ToggleLeft("Directly-navigate Menus during Conversations?", keyboardControlWhenDialogOptions, "AC.KickStarter.menuManager.keyboardControlWhenDialogOptions", "If True, then Menus will be navigated directly, not with the cursor, when Conversation dialogue options are shown"); if (AdvGame.GetReferences().settingsManager != null && AdvGame.GetReferences().settingsManager.inputMethod == InputMethod.KeyboardOrController) { autoSelectValidRaycasts = CustomGUILayout.ToggleLeft("Auto-select valid UI raycasts?", autoSelectValidRaycasts, "AC.KickStarter.menuManager.autoSelectValidRaycasts", "If True, then the simulated cursor will auto-select valid Unity UI elements"); } } if (drawInEditor && KickStarter.menuPreview == null) { EditorGUILayout.HelpBox("A GameEngine is required to display menus while editing - please set up the scene using the Scene Manager.", MessageType.Warning); } else if (drawInEditor && KickStarter.mainCamera == null) { EditorGUILayout.HelpBox("An AC MainCamera is required to display menus while editing - please set up the scene using the Scene Manager.", MessageType.Warning); } else if (Application.isPlaying) { EditorGUILayout.HelpBox("Changes made to the menus will not be registed by the game until the game is restarted.", MessageType.Info); } } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); CreateMenusGUI(); if (selectedMenu != null && menus.Contains(selectedMenu)) { EditorGUILayout.Space(); string menuTitle = selectedMenu.title; if (menuTitle == "") { menuTitle = "(Untitled)"; } EditorGUILayout.BeginVertical(CustomStyles.thinBox); showMenuProperties = CustomGUILayout.ToggleHeader(showMenuProperties, "Menu " + selectedMenu.id + ": '" + menuTitle + "' properties"); if (showMenuProperties) { selectedMenu.ShowGUI(); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.BeginVertical(CustomStyles.thinBox); showElementList = CustomGUILayout.ToggleHeader(showElementList, "Menu " + selectedMenu.id + ": '" + menuTitle + "' elements"); if (showElementList) { CreateElementsGUI(selectedMenu); } EditorGUILayout.EndVertical(); if (selectedMenuElement != null && selectedMenu.elements.Contains(selectedMenuElement)) { EditorGUILayout.Space(); string elementName = selectedMenuElement.title; if (elementName == "") { elementName = "(Untitled)"; } string elementType = ""; foreach (string _elementType in elementTypes) { if (selectedMenuElement.GetType().ToString().Contains(_elementType)) { elementType = _elementType; break; } } EditorGUILayout.BeginVertical(CustomStyles.thinBox); showElementProperties = CustomGUILayout.ToggleHeader(showElementProperties, elementType + " " + selectedMenuElement.ID + ": '" + elementName + "' properties"); if (showElementProperties) { oldVisibility = selectedMenuElement.IsVisible; selectedMenuElement.ShowGUIStart(selectedMenu); } else { EditorGUILayout.EndVertical(); } if (selectedMenuElement.IsVisible != oldVisibility) { if (!Application.isPlaying) { selectedMenu.Recalculate(); } } } } if (GUI.changed) { EditorUtility.SetDirty(this); } }