Exemplo n.º 1
0
        // Collapse button is clicked
        public void CollapseButtonPressed()
        {
            // Swap the value of collapse mode
            isCollapseOn = !isCollapseOn;

            snapToBottom         = true;
            collapseButton.color = isCollapseOn ? collapseButtonSelectedColor : collapseButtonNormalColor;
            recycledListView.SetCollapseMode(isCollapseOn);

            // Determine the new list of debug entries to show
            FilterLogs();
        }
Exemplo n.º 2
0
        private void OnEnable()
        {
            // Only one instance of debug console is allowed
            if (instance == null)
            {
                instance       = this;
                pooledLogItems = new List <DebugLogItem>();

                canvasTR = (RectTransform)transform;

                // Associate sprites with log types
                logSpriteRepresentations = new Dictionary <LogType, Sprite>
                {
                    { LogType.Log, infoLog },
                    { LogType.Warning, warningLog },
                    { LogType.Error, errorLog },
                    { LogType.Exception, errorLog },
                    { LogType.Assert, errorLog }
                };

                // Set initial button colors
                collapseButton.color   = isCollapseOn ? collapseButtonSelectedColor : collapseButtonNormalColor;
                filterInfoButton.color = (logFilter & DebugLogFilter.Info) == DebugLogFilter.Info
                                                ? filterButtonsSelectedColor : filterButtonsNormalColor;
                filterWarningButton.color = (logFilter & DebugLogFilter.Warning) == DebugLogFilter.Warning
                                                ? filterButtonsSelectedColor : filterButtonsNormalColor;
                filterErrorButton.color = (logFilter & DebugLogFilter.Error) == DebugLogFilter.Error
                                                ? filterButtonsSelectedColor : filterButtonsNormalColor;

                collapsedLogEntries          = new List <DebugLogEntry>(128);
                collapsedLogEntriesMap       = new Dictionary <DebugLogEntry, int>(128);
                uncollapsedLogEntriesIndices = new DebugLogIndexList();
                indicesOfListEntriesToShow   = new DebugLogIndexList();

                recycledListView.Initialize(this, collapsedLogEntries, indicesOfListEntriesToShow, logItemPrefab.Transform.sizeDelta.y);
                recycledListView.SetCollapseMode(isCollapseOn);
                recycledListView.UpdateItemsInTheList(true);

                nullPointerEventData = new PointerEventData(null);

                // If it is a singleton object, don't destroy it between scene changes
                if (singleton)
                {
                    DontDestroyOnLoad(gameObject);
                }
            }
            else if (this != instance)
            {
                Destroy(gameObject);
                return;
            }

            // Intercept debug entries
            Application.logMessageReceived -= ReceivedLog;
            Application.logMessageReceived += ReceivedLog;

            // Listen for entered commands
            commandInputField.onValidateInput -= OnValidateCommand;
            commandInputField.onValidateInput += OnValidateCommand;

            if (minimumHeight < 200f)
            {
                minimumHeight = 200f;
            }

            //Debug.LogAssertion( "assert" );
            //Debug.LogError( "error" );
            //Debug.LogException( new System.IO.EndOfStreamException() );
            //Debug.LogWarning( "warning" );
            //Debug.Log( "log" );

            //FPS Counter on for mobile only
            if (Application.isMobilePlatform)
            {
                fpsCounter.enabled = true;
            }
            else
            {
                fpsCounter.enabled = false;
            }
        }