Beispiel #1
0
        void Update()
        {
            if (!modListUpdated && config.improvedWorkshopIntegration)
            {
                ImprovedWorkshopIntegration.RefreshPlugins();
                modListUpdated = true;
            }

            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.W))
            {
                watches.visible = !watches.visible;
            }

            if (useModToolsConsole && Input.GetKeyDown(KeyCode.F7))
            {
                console.visible = !console.visible;
            }
        }
Beispiel #2
0
        void DoMainWindow()
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("Use ModTools console");
            var newUseConsole = GUILayout.Toggle(useModToolsConsole, "");

            GUILayout.EndHorizontal();

            if (newUseConsole != useModToolsConsole)
            {
                useModToolsConsole = newUseConsole;

                if (useModToolsConsole)
                {
                    console = gameObject.AddComponent <Console>();
                }
                else
                {
                    config.hookUnityLogging = false;
                    UnityLoggingHook.DisableHook();
                    Destroy(console);
                    console = null;
                }

                SaveConfig();
            }

            if (!config.useModToolsConsole)
            {
                GUI.enabled = false;
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label("Hook Unity's logging");
            var newHookLogging = GUILayout.Toggle(config.hookUnityLogging, "");

            GUILayout.EndHorizontal();

            if (newHookLogging != config.hookUnityLogging)
            {
                config.hookUnityLogging = newHookLogging;
                SaveConfig();

                if (config.hookUnityLogging)
                {
                    UnityLoggingHook.EnableHook();
                }
                else
                {
                    UnityLoggingHook.DisableHook();
                }
            }

            GUI.enabled = true;

            GUILayout.BeginHorizontal();
            GUILayout.Label("Log exceptions to console");
            logExceptionsToConsole = GUILayout.Toggle(logExceptionsToConsole, "");
            GUILayout.EndHorizontal();
            if (logExceptionsToConsole != config.logExceptionsToConsole)
            {
                SaveConfig();
            }

            if ((updateMode == SimulationManager.UpdateMode.NewGame || updateMode == SimulationManager.UpdateMode.LoadGame))
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Game panel extensions");
                var newExtendGamePanels = GUILayout.Toggle(extendGamePanels, "");
                GUILayout.EndHorizontal();

                if (newExtendGamePanels != extendGamePanels)
                {
                    extendGamePanels = newExtendGamePanels;
                    SaveConfig();

                    if (extendGamePanels)
                    {
                        gameObject.AddComponent <GamePanelExtender>();
                    }
                    else
                    {
                        Destroy(gameObject.GetComponent <GamePanelExtender>());
                    }
                }
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label("Improved Workshop integration");
            var improvedWorkshopIntegration = GUILayout.Toggle(config.improvedWorkshopIntegration, "");

            GUILayout.EndHorizontal();
            if (improvedWorkshopIntegration != config.improvedWorkshopIntegration)
            {
                config.improvedWorkshopIntegration = improvedWorkshopIntegration;
                if (config.improvedWorkshopIntegration && updateMode == SimulationManager.UpdateMode.Undefined)
                {
                    ImprovedWorkshopIntegration.Bootstrap();
                    ImprovedWorkshopIntegration.RefreshPlugins();
                }
                else if (updateMode == SimulationManager.UpdateMode.Undefined)
                {
                    ImprovedWorkshopIntegration.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("Throw exception!"))
            {
                throw new Exception("Hello world!");
            }
        }