public override void OnLevelLoaded(LoadMode mode) { base.OnLevelLoaded(mode); CustomPrefabs.Bootstrap(); var appMode = Singleton <ToolManager> .instance.m_properties.m_mode; var modTools = ModTools.Instance; if (modTools == null) { UnityEngine.Debug.LogError("ModTools instance wasn't present"); return; } if (modTools.config.extendGamePanels && appMode == ItemClass.Availability.Game) { modTools.gameObject.AddComponent <GamePanelExtender>(); } }
public static void Load() { CustomPrefabs.Bootstrap(); var appMode = Singleton <ToolManager> .instance.m_properties.m_mode; var modTools = MainWindow.Instance; if (modTools == null) { Debug.LogError("ModTools instance wasn't present"); return; } if (modTools.Config.ExtendGamePanels && appMode == ItemClass.Availability.Game) { modTools.gameObject.AddComponent <GamePanelExtension>(); } var selectionToolGo = new GameObject("SelectionToolControl"); selectionToolGo.transform.parent = GameObject.Find(ModToolsMod.ModToolsName).transform; selectionToolGo.AddComponent <SelectionToolControl>(); }
protected override void DrawWindow() { var newUseConsole = GUILayout.Toggle(Config.UseModToolsConsole, " Use ModTools console"); if (newUseConsole != Config.UseModToolsConsole) { Config.UseModToolsConsole = newUseConsole; if (Config.UseModToolsConsole) { console = gameObject.AddComponent <CustomConsole>(); Logger.SetCustomLogger(console); } else { Destroy(console); console = null; Logger.SetCustomLogger(null); } SaveConfig(); } GUILayout.BeginHorizontal(); GUILayout.Label("Console log level"); var newLogLevel = GUILayout.SelectionGrid(Config.LogLevel, new[] { "Log", "Warn", "Err", "None" }, 4); GUILayout.EndHorizontal(); if (newLogLevel != Config.LogLevel) { Config.LogLevel = newLogLevel; SaveConfig(); } var newLogExceptionsToConsole = GUILayout.Toggle(Config.LogExceptionsToConsole, " Log stack traces to console"); if (newLogExceptionsToConsole != Config.LogExceptionsToConsole) { Config.LogExceptionsToConsole = newLogExceptionsToConsole; SaveConfig(); } var newExtendGamePanels = GUILayout.Toggle(Config.ExtendGamePanels, " Game panel extensions"); if (newExtendGamePanels != Config.ExtendGamePanels) { Config.ExtendGamePanels = newExtendGamePanels; SaveConfig(); if (ToolManager.instance.m_properties.m_mode == ItemClass.Availability.Game) { var gamePanelExtender = gameObject.GetComponent <GamePanelExtension>(); if (Config.ExtendGamePanels) { if (gamePanelExtender == null) { gameObject.AddComponent <GamePanelExtension>(); } } else if (gamePanelExtender != null) { Destroy(gamePanelExtender); } } } if (debugRenderer == null) { debugRenderer = FindObjectOfType <UIView>().gameObject.AddComponent <DebugRenderer>(); } debugRenderer.DrawDebugInfo = GUILayout.Toggle( debugRenderer.DrawDebugInfo, $" Debug Renderer ({SettingsUI.DebugRendererKey})"); var customPrefabsObject = GUILayout.Toggle(Config.CustomPrefabsObject, " ModTools.CustomPrefabs Object"); if (customPrefabsObject != Config.CustomPrefabsObject) { Config.CustomPrefabsObject = customPrefabsObject; if (Config.CustomPrefabsObject) { CustomPrefabs.Bootstrap(); } else { CustomPrefabs.Revert(); } SaveConfig(); } var newSelectionTool = GUILayout.Toggle( Config.SelectionTool, $" Selection Tool ({SettingsUI.SelectionToolKey})"); if (newSelectionTool != Config.SelectionTool) { if (!newSelectionTool) { var tool = ToolsModifierControl.GetTool <SelectionTool>(); if (tool?.enabled == true) { ToolsModifierControl.SetTool <DefaultTool>(); } } Config.SelectionTool = newSelectionTool; SaveConfig(); } GUILayout.Space(Config.TreeIdentSpacing); if (GUILayout.Button($"Debug console ({SettingsUI.ConsoleKey})")) { if (console != null) { console.Visible = true; } else { var debugOutputPanel = GameObject.Find("(Library) DebugOutputPanel").GetComponent <DebugOutputPanel>(); debugOutputPanel.enabled = true; debugOutputPanel.GetComponent <UIPanel>().isVisible = true; } } if (GUILayout.Button($"Watches ({SettingsUI.WatchesKey})")) { Watches.Visible = !Watches.Visible; } if (GUILayout.Button($"Scene explorer ({SettingsUI.SceneExplorerKey})")) { SceneExplorer.Visible = !SceneExplorer.Visible; if (SceneExplorer.Visible) { SceneExplorer.RefreshSceneRoots(); } } if (GUILayout.Button($"Script editor ({SettingsUI.ScriptEditorKey})")) { scriptEditor.Visible = !scriptEditor.Visible; } GUILayout.FlexibleSpace(); if (GUILayout.Button("Appearance settings")) { appearanceConfig.Visible = true; var windowRect = appearanceConfig.WindowRect; windowRect.position = WindowRect.position + new Vector2(32.0f, 32.0f); appearanceConfig.MoveResize(windowRect); } }
void DoMainWindow() { GUILayout.BeginHorizontal(); GUILayout.Label("Use ModTools console"); var newUseConsole = GUILayout.Toggle(config.useModToolsConsole, ""); GUILayout.EndHorizontal(); if (newUseConsole != config.useModToolsConsole) { config.useModToolsConsole = newUseConsole; if (config.useModToolsConsole) { console = gameObject.AddComponent <Console>(); } else { Destroy(console); console = null; } SaveConfig(); } GUILayout.BeginHorizontal(); GUILayout.Label("Console log level"); var newLogLevel = GUILayout.SelectionGrid(config.logLevel, new[] { "Log", "Warn", "Err", "None" }, 4); GUILayout.EndHorizontal(); if (newLogLevel != config.logLevel) { config.logLevel = newLogLevel; SaveConfig(); } GUILayout.BeginHorizontal(); GUILayout.Label("Log stack traces to console"); var newLogExceptionsToConsole = GUILayout.Toggle(config.logExceptionsToConsole, ""); GUILayout.EndHorizontal(); if (newLogExceptionsToConsole != config.logExceptionsToConsole) { config.logExceptionsToConsole = newLogExceptionsToConsole; SaveConfig(); } GUILayout.BeginHorizontal(); GUILayout.Label("Game panel extensions"); var newExtendGamePanels = GUILayout.Toggle(config.extendGamePanels, ""); GUILayout.EndHorizontal(); if (newExtendGamePanels != config.extendGamePanels) { config.extendGamePanels = newExtendGamePanels; SaveConfig(); if (config.extendGamePanels) { gameObject.AddComponent <GamePanelExtender>(); } else { Destroy(gameObject.GetComponent <GamePanelExtender>()); } } GUILayout.BeginHorizontal(); if (debugRenderer == null) { debugRenderer = GameObject.FindObjectOfType <UIView>().gameObject.AddComponent <DebugRenderer>(); } GUILayout.Label("Debug Renderer (Ctrl+R)"); debugRenderer.drawDebugInfo = GUILayout.Toggle(debugRenderer.drawDebugInfo, ""); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Custom Prefabs Object"); var customPrefabsObject = GUILayout.Toggle(config.customPrefabsObject, ""); GUILayout.EndHorizontal(); if (customPrefabsObject != config.customPrefabsObject) { config.customPrefabsObject = customPrefabsObject; if (config.customPrefabsObject) { CustomPrefabs.Bootstrap(); } else { CustomPrefabs.Revert(); } SaveConfig(); } if (GUILayout.Button("Debug console (F7)")) { if (console != null) { console.visible = true; } else { var debugOutputPanel = GameObject.Find("(Library) DebugOutputPanel").GetComponent <DebugOutputPanel>(); debugOutputPanel.enabled = true; debugOutputPanel.GetComponent <UIPanel>().isVisible = true; } } if (GUILayout.Button("Watches (Ctrl+W)")) { watches.visible = !watches.visible; } if (GUILayout.Button("Scene explorer (Ctrl+E)")) { sceneExplorer.visible = !sceneExplorer.visible; if (sceneExplorer.visible) { sceneExplorer.Refresh(); } } if (GUILayout.Button("Script editor (Ctrl+`)")) { scriptEditor.visible = !scriptEditor.visible; } }