public void Initialize(DebugLogManager manager, List <DebugLogEntry> collapsedLogEntries, DebugLogIndexList indicesOfEntriesToShow, float logItemHeight)
 {
     this.manager                = manager;
     this.collapsedLogEntries    = collapsedLogEntries;
     this.indicesOfEntriesToShow = indicesOfEntriesToShow;
     this.logItemHeight          = logItemHeight;
     _1OverLogItemHeight         = 1f / logItemHeight;
 }
Esempio n. 2
0
        private void Awake()
        {
            // Only one instance of debug console is allowed
            if (instance == null)
            {
                instance = this;

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

            pooledLogEntries = new List <DebugLogEntry>(16);
            pooledLogItems   = new List <DebugLogItem>(16);
            queuedLogEntries = new DynamicCircularBuffer <QueuedDebugLogEntry>(16);
            commandHistory   = new CircularBuffer <string>(commandHistorySize);

            logEntriesLock = new object();

            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 }
            };

            // Initially, all log types are visible
            filterInfoButton.color    = filterButtonsSelectedColor;
            filterWarningButton.color = filterButtonsSelectedColor;
            filterErrorButton.color   = filterButtonsSelectedColor;

            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.UpdateItemsInTheList(true);

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

            nullPointerEventData = new PointerEventData(null);
        }
Esempio n. 3
0
        public static void SaveLogsToFile()
        {
            string path = string.Concat(Application.dataPath.Remove(Application.dataPath.Length - 6)
                                        , "Log_"
                                        , System.DateTime.Now.ToString("dd-MM-yyyy_hh-mm-ss")
                                        , ".txt"
                                        );

            try
            {
                File.WriteAllText(path, DebugLogManager.GetAllLogs());
                Debug.Log("Logs saved to: " + path);
            }
            catch (System.Exception e)
            {
                Debug.LogError("Error saving logs\n" + e.ToString());
            }
        }
 // This log item is clicked, show the debug entry's stack trace
 public void Clicked()
 {
     DebugLogManager.OnLogClicked(entryIndex);
 }
Esempio n. 5
0
        void OnEnable()
        {
            // Only one instance of debug console is allowed
            if (instance == null)
            {
                instance       = this;
                pooledLogItems = new List <DebugLogItem>();

                canvasTR = 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 }
                };

                // Initially, all log types are visible
                filterInfoButton.color    = filterButtonsSelectedColor;
                filterWarningButton.color = filterButtonsSelectedColor;
                filterErrorButton.color   = filterButtonsSelectedColor;

                // When collapse is disabled and all log types are visible (initial state),
                // the order of the debug entries to show on screen is the same as
                // the order they were intercepted
                collapsedLogEntries          = new List <DebugLogEntry>();
                uncollapsedLogEntriesIndices = new List <int>();
                indicesOfListEntriesToShow   = uncollapsedLogEntriesIndices;

                recycledListView.SetLogItemHeight(logItemPrefab.Transform.sizeDelta.y);
                recycledListView.SetCollapsedEntriesList(collapsedLogEntries);
                recycledListView.SetEntryIndicesList(indicesOfListEntriesToShow);

                // 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;

            if (receiveLogcatLogsInAndroid)
            {
                if (logcatListener == null)
                {
                    logcatListener = new DebugLogLogcatListener();
                }

                logcatListener.Start(logcatArguments);
            }

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

            /*Debug.LogAssertion( "assert" );
             * Debug.LogError( "error" );
             * Debug.LogException( new System.IO.EndOfStreamException() );
             * Debug.LogWarning( "warning" );
             * Debug.Log( "log" );*/
        }
        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 }
                };
                inputCommandHistory = new LinkedList <string>();

                // Initially, all log types are visible
                filterInfoButton.color    = filterButtonsSelectedColor;
                filterWarningButton.color = filterButtonsSelectedColor;
                filterErrorButton.color   = filterButtonsSelectedColor;

                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.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;

            if (receiveLogcatLogsInAndroid)
            {
#if !UNITY_EDITOR && UNITY_ANDROID
                if (logcatListener == null)
                {
                    logcatListener = new DebugLogLogcatListener();
                }

                logcatListener.Start(logcatArguments);
#endif
            }

            // 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" );
        }
 private void Start()
 {
     m_Manager = m_Manager ? m_Manager : (m_Manager = GetComponent <DebugLogManager>());
     m_PopUp   = m_PopUp ? m_PopUp : (m_PopUp = GetComponentInChildren <DebugLogPopup>());
 }
Esempio n. 8
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;
            }
        }