コード例 #1
0
        /// <summary>
        /// Outputs the message object to the console, prefixed with the current timestamp
        /// </summary>
        /// <param name="message">Message.</param>
        public static void DebugLogTime(object message, string color = "", int timePrecision = 3, bool displayFrameCount = true)
        {
            if (!DebugLogsEnabled)
            {
                return;
            }

            // colors
            string colorPrefix = "";
            string colorSuffix = "";

            if (!string.IsNullOrEmpty(color))
            {
                colorPrefix = "<color=" + color + ">";
                colorSuffix = "</color>";
            }

            // build output
            string output = "";

            if (displayFrameCount)
            {
                output += "<color=#82d3f9>[" + Time.frameCount + "]</color> ";
            }
            output += "<color=#f9a682>[" + MMTime.FloatToTimeString(Time.time, false, true, true, true) + "]</color> ";
            output += colorPrefix + message + colorSuffix;

            // output
            Debug.Log(output);
        }
コード例 #2
0
        /// <summary>
        /// Refreshes the text component at the specified refresh frequency
        /// </summary>
        protected virtual void UpdateText()
        {
            if (Time.time - _lastRefreshAt > RefreshFrequency)
            {
                if (_text != null)
                {
                    string newText = "";

                    if (FormatMethod == FormatMethods.Explicit)
                    {
                        if (FloorValues)
                        {
                            newText = Mathf.Floor(CurrentTime).ToString(Format);
                        }
                        else
                        {
                            newText = CurrentTime.ToString(Format);
                        }
                    }
                    else
                    {
                        newText = MMTime.FloatToTimeString(CurrentTime, Hours, Minutes, Seconds, Milliseconds);
                    }

                    _text.text = newText;
                }
                if (CountdownRefreshEvent != null)
                {
                    CountdownRefreshEvent.Invoke();
                }
                _lastRefreshAt = Time.time;
            }
        }
コード例 #3
0
        /// <summary>
        /// A debug method used to output console messages, for this class only
        /// </summary>
        /// <param name="message"></param>
        protected virtual void MMLoadingSceneDebug(string message)
        {
            if (!DebugMode)
            {
                return;
            }

            string output = "";

            output += "<color=#82d3f9>[" + Time.frameCount + "]</color> ";
            output += "<color=#f9a682>[" + MMTime.FloatToTimeString(Time.time, false, true, true, true) + "]</color> ";
            output += message;
            Debug.Log(output);
        }
コード例 #4
0
        /// <summary>
        /// Outputs the message object to the console, prefixed with the current timestamp
        /// </summary>
        /// <param name="message">Message.</param>
        public static void DebugLogTime(object message, string color = "", int timePrecision = 3, bool displayFrameCount = true)
        {
            if (!DebugLogsEnabled)
            {
                return;
            }

            string callerObjectName = new StackTrace().GetFrame(1).GetMethod().ReflectedType.Name;

            color = (color == "") ? "#00FFFF" : color;

            // colors
            string colorPrefix = "";
            string colorSuffix = "";

            if (!string.IsNullOrEmpty(color))
            {
                colorPrefix = "<color=" + color + ">";
                colorSuffix = "</color>";
            }

            // build output
            string output = "";

            if (displayFrameCount)
            {
                output += "<color=#82d3f9>[f" + Time.frameCount + "]</color> ";
            }
            output += "<color=#f9a682>[" + MMTime.FloatToTimeString(Time.time, false, true, true, true) + "]</color> ";
            output += callerObjectName + " : ";
            output += colorPrefix + message + colorSuffix;

            // we output to the console
            Debug.Log(output);

            DebugLogItem item = new DebugLogItem(message, color, Time.frameCount, Time.time, timePrecision, displayFrameCount);

            // we add to our DebugLog
            if (LogHistory.Count > _logHistoryMaxLength)
            {
                LogHistory.RemoveAt(0);
            }

            LogHistory.Add(item);

            // we trigger an event
            MMDebugLogEvent.Trigger(item);
        }