Пример #1
0
        public ConsoleMessage GetNewMessage(PoolType type)
        {
            GameObject     messageObj = null;
            ConsoleMessage message    = null;

            CheckPoolAvailability(type);

            switch (type)
            {
            case PoolType.Log:
                messageObj = logPool.Dequeue();
                ConsoleLogMessage temp = messageObj.GetComponent <ConsoleLogMessage>();
                if (temp)
                {
                    message = temp;
                }
                break;

            case PoolType.Command:
                messageObj = commandPool.Dequeue();
                ConsoleCommandMessage temp2 = messageObj.GetComponent <ConsoleCommandMessage>();
                if (temp2)
                {
                    message = temp2;
                }
                break;
            }

            messageObj.transform.SetParent(contentParent);
            messageObj.SetActive(true);
            return(message);
        }
Пример #2
0
        private void Log(string condition, string stackTrace, LogType type)
        {
            ConsoleLogMessage newMessage = (ConsoleLogMessage)pool.GetNewMessage(ConsolePool.PoolType.Log);

            string trace = stackTrace;

            if (config.stackTraceFormat == ConsoleConfig.StackTraceFormat.System_Experimental)
            {
                // Manually get stacktrace, Unity hides the stacktrace in normal builds.
                System.Diagnostics.StackTrace systemStackTrace = new System.Diagnostics.StackTrace(true);
                trace = systemStackTrace.ToString();

                trace = trace.Remove(0, 2);
                trace = trace.Replace("at ", "<b>at</b> ");

                // Remove hex values
                int start = trace.IndexOf("[0x");
                while (start > 0)
                {
                    trace = trace.Remove(start, 10);
                    start = trace.IndexOf("[0x");
                }
            }

            if (config.stackTraceLineNumberHighlights)
            {
                trace = trace.Replace(")\n", "</color>)\n");
                trace = trace.Replace(".cs:", $".cs:<color=#{ColorUtility.ToHtmlStringRGB(config.stackTraceHighlightColor)}>");
            }

            LogData newLogData = CreateLogData(condition, trace, type);

            newMessage.Init(newLogData);

            messages.Add(newMessage);

            newMessage.gameObject.SetActive(FilterMessage(newMessage));
            TryCollapseMessage(newMessage);

            StartCoroutine(UpdateWindowScrollPositions());
        }