コード例 #1
0
        public static void Initialize(Dictionary <string, MethodInfo> commands = null)
        {
            if (instance)
            {
                return;
            }

            CommandDatabase.RegisterCommands(commands);

            var hostObject = new GameObject("UnityConsole");

            hostObject.hideFlags = HideFlags.HideAndDontSave;
            DontDestroyOnLoad(hostObject);

            instance       = hostObject.AddComponent <ConsoleGUI>();
            instance.style = new GUIStyle {
                normal = new GUIStyleState {
                    background = Texture2D.whiteTexture, textColor = Color.white
                },
                contentOffset = new Vector2(5, 5),
            };

            instance.guiProxy = hostObject.AddComponent <OnGUIProxy>();
            instance.guiProxy.OnGUIDelegate = instance.DrawGUI;
            instance.guiProxy.enabled       = false;
        }
コード例 #2
0
        private static void SetupDevelopmentConsole()
        {
            if (Engine.Initialized)
            {
                OnInitializationFinished();
            }
            else
            {
                Engine.OnInitializationFinished += OnInitializationFinished;
            }

            void OnInitializationFinished()
            {
                Engine.OnInitializationFinished -= OnInitializationFinished;
                if (!Engine.Configuration.EnableDevelopmentConsole)
                {
                    return;
                }

                ConsoleGUI.ToggleKey = Engine.Configuration.ToggleConsoleKey;
                ConsoleGUI.Initialize();

                // Process input starting with `@` as naninovel commands.
                InputPreprocessor.AddPreprocessor(ProcessActionInput);
            }
        }