// If snapToBottom is enabled, force the scrollbar to the bottom
    void LateUpdate()
    {
        if (screenDimensionsChanged)
        {
            // Update the recycled list view
            if (isLogWindowVisible)
            {
                recycledListView.OnViewportDimensionsChanged();
            }
            else
            {
                popupManager.OnViewportDimensionsChanged();
            }
            screenDimensionsChanged = false;
        }

        if (snapToBottom)
        {
            logItemsScrollRect.verticalNormalizedPosition = 0f;

            if (snapToBottomButton.activeSelf)
            {
                snapToBottomButton.SetActive(false);
            }
        }
        else
        {
            float scrollPos = logItemsScrollRect.verticalNormalizedPosition;
            if (snapToBottomButton.activeSelf != (scrollPos > 1E-6f && scrollPos < 0.9999f))
            {
                snapToBottomButton.SetActive(!snapToBottomButton.activeSelf);
            }
        }

#if !UNITY_EDITOR && UNITY_ANDROID
        if (logcatListener != null)
        {
            string log;
            while ((log = logcatListener.GetLog()) != null)
            {
                ReceivedLog("LOGCAT: " + log, string.Empty, LogType.Log);
            }
        }
#endif
    }
Exemplo n.º 2
0
        private void LateUpdate()
        {
#if UNITY_EDITOR
            if (isQuittingApplication)
            {
                return;
            }
#endif

            int queuedLogCount = queuedLogEntries.Count;
            if (queuedLogCount > 0)
            {
                for (int i = 0; i < queuedLogCount; i++)
                {
                    QueuedDebugLogEntry logEntry;
                    lock ( logEntriesLock )
                    {
                        logEntry = queuedLogEntries.RemoveFirst();
                    }

                    ProcessLog(logEntry);
                }
            }

            if (screenDimensionsChanged)
            {
                // Update the recycled list view
                if (isLogWindowVisible)
                {
                    recycledListView.OnViewportDimensionsChanged();
                }
                else
                {
                    popupManager.OnViewportDimensionsChanged();
                }

                screenDimensionsChanged = false;
            }

            // If snapToBottom is enabled, force the scrollbar to the bottom
            if (snapToBottom)
            {
                logItemsScrollRect.verticalNormalizedPosition = 0f;

                if (snapToBottomButton.activeSelf)
                {
                    snapToBottomButton.SetActive(false);
                }
            }
            else
            {
                float scrollPos = logItemsScrollRect.verticalNormalizedPosition;
                if (snapToBottomButton.activeSelf != (scrollPos > 1E-6f && scrollPos < 0.9999f))
                {
                    snapToBottomButton.SetActive(!snapToBottomButton.activeSelf);
                }
            }

            if (toggleWithKey)
            {
                if (Input.GetKeyDown(toggleKey))
                {
                    if (isLogWindowVisible)
                    {
                        ShowPopup();
                    }
                    else
                    {
                        ShowLogWindow();
                    }
                }
            }

            if (isLogWindowVisible && commandInputField.isFocused)
            {
                if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    if (commandHistoryIndex == -1)
                    {
                        commandHistoryIndex = commandHistory.Count - 1;
                    }
                    else if (--commandHistoryIndex < 0)
                    {
                        commandHistoryIndex = 0;
                    }

                    if (commandHistoryIndex >= 0 && commandHistoryIndex < commandHistory.Count)
                    {
                        commandInputField.text          = commandHistory[commandHistoryIndex];
                        commandInputField.caretPosition = commandInputField.text.Length;
                    }
                }
                else if (Input.GetKeyDown(KeyCode.DownArrow))
                {
                    if (commandHistoryIndex == -1)
                    {
                        commandHistoryIndex = commandHistory.Count - 1;
                    }
                    else if (++commandHistoryIndex >= commandHistory.Count)
                    {
                        commandHistoryIndex = commandHistory.Count - 1;
                    }

                    if (commandHistoryIndex >= 0 && commandHistoryIndex < commandHistory.Count)
                    {
                        commandInputField.text = commandHistory[commandHistoryIndex];
                    }
                }
            }

#if !UNITY_EDITOR && UNITY_ANDROID
            if (logcatListener != null)
            {
                string log;
                while ((log = logcatListener.GetLog()) != null)
                {
                    ReceivedLog("LOGCAT: " + log, string.Empty, LogType.Log);
                }
            }
#endif
        }