Esempio n. 1
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
        }
Esempio 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();
                }

#if UNITY_ANDROID || UNITY_IOS
                CheckScreenCutout();
#endif

                if (searchbar)
                {
                    float logWindowWidth = logWindowTR.rect.width;
                    if (logWindowWidth >= topSearchbarMinWidth)
                    {
                        if (searchbar.parent == searchbarSlotBottom)
                        {
                            searchbarSlotTop.gameObject.SetActive(true);
                            searchbar.SetParent(searchbarSlotTop, false);
                            searchbarSlotBottom.gameObject.SetActive(false);

                            logItemsScrollRectTR.anchoredPosition = Vector2.zero;
                            logItemsScrollRectTR.sizeDelta        = logItemsScrollRectOriginalSize;
                        }
                    }
                    else
                    {
                        if (searchbar.parent == searchbarSlotTop)
                        {
                            searchbarSlotBottom.gameObject.SetActive(true);
                            searchbar.SetParent(searchbarSlotBottom, false);
                            searchbarSlotTop.gameObject.SetActive(false);

                            float searchbarHeight = searchbarSlotBottom.sizeDelta.y;
                            logItemsScrollRectTR.anchoredPosition = new Vector2(0f, searchbarHeight * -0.5f);
                            logItemsScrollRectTR.sizeDelta        = logItemsScrollRectOriginalSize - new Vector2(0f, searchbarHeight);
                        }
                    }
                }

                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 !UNITY_EDITOR && UNITY_ANDROID
            if (logcatListener != null)
            {
                string log;
                while ((log = logcatListener.GetLog()) != null)
                {
                    ReceivedLog("LOGCAT: " + log, string.Empty, LogType.Log);
                }
            }
#endif
        }