private void Awake()
        {
            if (Singleton != null)
            {
                Destroy(gameObject);
                return;
            }

            Singleton = this;
            DontDestroyOnLoad(gameObject);

            canvas           = GetComponent <Canvas>();
            graphicRaycaster = GetComponent <GraphicRaycaster>();

            SceneManager.sceneLoaded += SceneLoaded;
        }
        private void LateUpdate()
        {
            if (!ConsoleCanvasController.IsVisible())
            {
                return;
            }

            bool upArrow   = Input.GetKeyDown(KeyCode.UpArrow);
            bool downArrow = Input.GetKeyDown(KeyCode.DownArrow);

            if (upArrow || downArrow)
            {
                if (typedText == "" && commandsHistory.Count > 0)
                {
                    if (upArrow)
                    {
                        commandsHistoryIndex++;          //auto get last
                    }
                    if (downArrow)
                    {
                        commandsHistoryIndex--;            //auto get first
                    }
                    if (commandsHistoryIndex < 0)
                    {
                        commandsHistoryIndex = commandsHistory.Count - 1;
                    }
                    if (commandsHistoryIndex >= commandsHistory.Count)
                    {
                        commandsHistoryIndex = 0;
                    }

                    consoleInput.text = commandsHistory[commandsHistoryIndex];
                    StartCoroutine(MoveToEndOfInput());
                }
                else
                {
                    string autocomplete = autoCompletionManager.GetAutoCompleteString();

                    if (autocomplete != "")
                    {
                        consoleInput.text = autocomplete + " ";
                    }
                    StartCoroutine(MoveToEndOfInput());
                }
            }

            #region Handling dragging and resizing console window
            if (Input.GetMouseButtonDown(0))
            {
                mouseStartClickPanelPosition   = transform.position;
                mouseStartClickPosition        = Input.mousePosition;
                mouseStartClickPanelSize       = rectTransform.sizeDelta;
                mouseStartClickPanelDifference = GetMouseDifference(mouseStartClickPosition);

                if (mouseStartClickPanelDifference.y < 34)
                {
                    isDragging = true;
                }

                if (mouseStartClickPanelDifference.x > rectTransform.sizeDelta.x - 18 &&
                    mouseStartClickPanelDifference.y > rectTransform.sizeDelta.y - 18)
                {
                    isResizing = true;
                }
            }
            else
            {
                if (isDragging)
                {
                    isDragging = Input.GetMouseButton(0);
                }
                if (isResizing)
                {
                    isResizing = Input.GetMouseButton(0);
                }
            }

            if (isDragging)
            {
                Vector2 movePosition = mouseStartClickPanelPosition + ((Vector2)Input.mousePosition - mouseStartClickPosition);;

                if (movePosition.x < 0)
                {
                    movePosition.x = 0;
                }
                if (movePosition.x / canvasScaler.transform.localScale.x > Screen.width / canvasScaler.transform.localScale.x - rectTransform.sizeDelta.x)
                {
                    movePosition.x = (Screen.width / canvasScaler.transform.localScale.x - rectTransform.sizeDelta.x) * canvasScaler.transform.localScale.x;
                }
                if (movePosition.y > Screen.height)
                {
                    movePosition.y = Screen.height;
                }
                if (movePosition.y / canvasScaler.transform.localScale.x < rectTransform.sizeDelta.y)
                {
                    movePosition.y = rectTransform.sizeDelta.y * canvasScaler.transform.localScale.x;
                }

                transform.position = movePosition;
            }

            if (isResizing)
            {
                Vector2 currentMousePosition = Input.mousePosition;

                if (currentMousePosition.x > Screen.width)
                {
                    currentMousePosition.x = Screen.width;
                }
                if (currentMousePosition.y < 6)
                {
                    currentMousePosition.y = 6;
                }

                float newWidth  = Mathf.Max(400, mouseStartClickPanelSize.x + (currentMousePosition.x - mouseStartClickPosition.x) / canvasScaler.transform.localScale.x);
                float newHeight = Mathf.Max(300, mouseStartClickPanelSize.y + (currentMousePosition.y - mouseStartClickPosition.y) / -canvasScaler.transform.localScale.x);

                rectTransform.sizeDelta = new Vector2(newWidth, newHeight);

                var pixelRect = RectTransformUtility.PixelAdjustRect(consoleOutputRect, testCanvas);

                textOutputWidth  = pixelRect.width;
                textOutputHeight = pixelRect.height;

                UpdateVerticalScrollbarSize();
                UpdateVisibleText();
            }
            #endregion
        }