Beispiel #1
0
        private void ExecuteInput()
        {
            if (string.IsNullOrWhiteSpace(input))
            {
                return;
            }

            var preprocessedInput = InputPreprocessor.PreprocessInput(input);

            if (string.IsNullOrWhiteSpace(preprocessedInput))
            {
                return;
            }

            var command = preprocessedInput.Split(separator, StringSplitOptions.RemoveEmptyEntries);

            if (command.Length == 0)
            {
                return;
            }
            if (command.Length == 1)
            {
                CommandDatabase.ExecuteCommand(command[0]);
            }
            else
            {
                CommandDatabase.ExecuteCommand(command[0], command.ToList().GetRange(1, command.Length - 1).ToArray());
            }
        }
Beispiel #2
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;
        }
Beispiel #3
0
        public static void Initialize()
        {
            if (hostObject)
            {
                return;
            }

            CommandDatabase.RegisterCommands();

            hostObject           = new GameObject("UnityConsole");
            hostObject.hideFlags = HideFlags.HideAndDontSave;
            DontDestroyOnLoad(hostObject);
            hostObject.AddComponent <ConsoleGUI>();
        }