Exemplo n.º 1
0
        public void Update()
        {
            var middleButtonState = MouseButtonState.None;

            if (Input.GetMouseButtonDown(2))
            {
                middleButtonState = MouseButtonState.Pressed;
            }
            else if (Input.GetMouseButtonUp(2))
            {
                middleButtonState = MouseButtonState.Released;
            }
            else if (Input.GetMouseButton(2))
            {
                middleButtonState = MouseButtonState.Held;
            }

            modalUI.Update(IsMouseOverWindow(), middleButtonState);

            if (SettingsUI.ConsoleKey.IsKeyUp())
            {
                console.Visible = !console.Visible;
            }
            else if (SettingsUI.MainWindowKey.IsKeyUp())
            {
                Visible = !Visible;
            }
            else if (SettingsUI.SceneExplorerKey.IsKeyUp())
            {
                SceneExplorer.Visible = !SceneExplorer.Visible;
                if (SceneExplorer.Visible)
                {
                    SceneExplorer.RefreshSceneRoots();
                }
            }
            else if (SettingsUI.DebugRendererKey.IsKeyUp())
            {
                if (!debugRenderer)
                {
                    debugRenderer = FindObjectOfType <UIView>().gameObject.AddComponent <DebugRenderer>();
                }
                debugRenderer.DrawDebugInfo = !debugRenderer.DrawDebugInfo;
            }
            else if (SettingsUI.WatchesKey.IsKeyUp())
            {
                Watches.Visible = !Watches.Visible;
            }
            else if (SettingsUI.ScriptEditorKey.IsKeyUp())
            {
                scriptEditor.Visible = !scriptEditor.Visible;
            }
        }
Exemplo n.º 2
0
        void Update()
        {
            UpdateMouseScrolling();

            if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.Q))
            {
                visible = !visible;
            }

            if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.E))
            {
                sceneExplorer.visible = !sceneExplorer.visible;
                if (sceneExplorer.visible)
                {
                    sceneExplorer.Refresh();
                }
            }

            if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.R))
            {
                if (debugRenderer == null)
                {
                    debugRenderer = GameObject.FindObjectOfType <UIView>().gameObject.AddComponent <DebugRenderer>();
                }
                debugRenderer.drawDebugInfo = !debugRenderer.drawDebugInfo;
            }

            if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.W))
            {
                watches.visible = !watches.visible;
            }

            if (config.useModToolsConsole && Input.GetKeyDown(KeyCode.F7))
            {
                console.visible = !console.visible;
            }

            if (Input.GetKeyDown(KeyCode.BackQuote))
            {
                scriptEditor.visible = !scriptEditor.visible;
            }
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
        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;
            }
        }