Пример #1
0
 public DebugMessageLine(DebugMessageLine line)
 {
     _message        = line._message;
     _stackTrace     = line._stackTrace;
     _color          = line._color;
     _count          = line._count;
     _maxHeight      = line._maxHeight;
     _lastChangeTime = line._lastChangeTime;
     _lastUpdateTime = line._lastUpdateTime;
     _type           = line._type;
     _deltatime      = line._deltatime;
 }
Пример #2
0
    public void SetMaxWidth(DebugMessageLine line)
    {
        if (line.maxHeight == 0)
        {
            line.maxHeight = 30;
        }

        else if (line.maxHeight == 30)
        {
            line.maxHeight = 250;
        }
        else if (line.maxHeight == 250)
        {
            line.maxHeight = 450;
        }
        else
        {
            line.maxHeight = 30;
        }
    }
Пример #3
0
 private bool CompareWisibleStatus(DebugMessageLine line)
 {
     if (enableWorning && line.type == LogType.Warning)
     {
         return(true);
     }
     if (enableAssert && line.type == LogType.Assert)
     {
         return(true);
     }
     if (enableException && line.type == LogType.Exception)
     {
         return(true);
     }
     if (enableError && line.type == LogType.Error)
     {
         return(true);
     }
     if (enableLog && line.type == LogType.Log)
     {
         return(true);
     }
     return(false);
 }
Пример #4
0
    void OnGUI()
    {
        DebugMessageLine[] messageLines = new DebugMessageLine[0];

        if (showGroup == null || !instance.lineDictionary.ContainsKey(showGroup))
        {
            showGroup = instance.lineDictionary.Keys.FirstOrDefault();
        }
        if (showGroup != null)
        {
            messageLines = instance.lineDictionary[showGroup].ToArray();
        }

#if TEST_VERSION
        GUI.Label(new Rect(10, Screen.height - 60, 300, 20), "last averageDeltaTime : " + ((int)(averageDeltaTime * 1000f)) / 1000f);
        GUI.Label(new Rect(10, Screen.height - 30, 300, 20), "last deltaTime: " + ((int)(deltaTime * 1000f)) / 1000f);

        minBtnWidth  = Screen.width / 1024f * 120f;
        minBtnHeight = Screen.height / 768f * 45f;

        //if(maximize)
        //	cHeight = Screen.height;
        //else
        cHeight = Mathf.Clamp(Screen.height / 3f * showLog, 0, Screen.height - minBtnHeight);

        /*
         *      if(NGUITools.FindCameraForLayer(8).GetComponent<UICamera>()==null)
         *              return;
         *      NGUITools.FindCameraForLayer(8).GetComponent<UICamera>().enabled = !(maximize&&showLog);
         */
        GUILayout.BeginHorizontal();

        if (showLog == 0)
        {
            GUILayout.Space(Screen.width / 2 - minBtnWidth / 2);
        }

        GUILayout.BeginVertical("box");

        if (showLog > 0)
        {
            GUI.skin.verticalScrollbar.fixedWidth      = Screen.width * 0.04f;
            GUI.skin.verticalScrollbarThumb.fixedWidth = GUI.skin.verticalScrollbar.fixedWidth;
            //GUILayout.BeginVertical();
            //GUILayout.BeginArea(new Rect(0,0,Screen.width, Screen.height/3),"Consol","box");
            GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));

            scrollGroupPosition = GUILayout.BeginScrollView(
                scrollGroupPosition, GUILayout.Width(Screen.width / 8), GUILayout.Height(cHeight - 100));
            GUILayout.BeginVertical();
            foreach (KeyValuePair <string, List <DebugMessageLine> > pair in instance.lineDictionary)
            {
                if (GUILayout.Button(pair.Key, GUILayout.Width(minBtnWidth), GUILayout.Height(minBtnHeight)))
                {
                    showGroup = pair.Key;
                }
            }
            GUILayout.EndVertical();

            GUILayout.EndScrollView();

            GUILayout.FlexibleSpace();

            scrollPosition = GUILayout.BeginScrollView(
                scrollPosition, GUILayout.Width(Screen.width - Screen.width / 8), GUILayout.MinHeight(cHeight - 100));

            foreach (DebugMessageLine line in messageLines)
            {
                if (CompareWisibleStatus(line))
                {
                    lineStyle.normal.textColor = line.color;
                    lineStyle.fontSize         = Screen.width / 1024 * 14;
                    lineStyle.wordWrap         = true;

                    GUILayout.BeginHorizontal("box");

                    if (GUILayout.Button(string.Format("{0}", line.message), lineStyle, GUILayout.Width(Screen.width - Screen.width / 4.1f), GUILayout.Height(line.maxHeight)))
                    {
                        SetMaxWidth(line);
                        //MobileDebug.Log(line.maxHeight);
                    }
                    lineStyle.fontSize = Screen.width / 1024 * 11;
                    GUILayout.Label(string.Format("count:{0}\nlastUpdate:\n{1} \nlastChange:\n{2}\ndeltatime:\n{3}", line.count.ToString(), line.lastUpdateTime.ToString("hh:mm:ss:ms"), line.lastChangeTime.ToString("hh:mm:ss:ms"), line.deltaTime), lineStyle, GUILayout.MinWidth(70));

                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.EndScrollView();
            GUILayout.EndHorizontal();
        }

        lineStyle.normal.textColor = Color.white;
        if (showLog > 0)
        {
            GUILayout.BeginHorizontal();

            if (GUILayout.Button(enableAssert?"Assert *":"Assert", GUILayout.MinWidth(minBtnWidth), GUILayout.MinHeight(minBtnHeight)))
            {
                enableAssert = !enableAssert;
            }
            if (GUILayout.Button(enableError?"Error *":"Error", GUILayout.MinWidth(minBtnWidth), GUILayout.MinHeight(minBtnHeight)))
            {
                enableError = !enableError;
            }
            if (GUILayout.Button(enableException?"Exception *":"Exception", GUILayout.MinWidth(minBtnWidth), GUILayout.MinHeight(minBtnHeight)))
            {
                enableException = !enableException;
            }
            if (GUILayout.Button(enableWorning?"Warning *":"Warning", GUILayout.MinWidth(minBtnWidth), GUILayout.MinHeight(minBtnHeight)))
            {
                enableWorning = !enableWorning;
            }
            if (GUILayout.Button(enableLog?"Log *":"Log", GUILayout.MinWidth(minBtnWidth), GUILayout.MinHeight(minBtnHeight)))
            {
                enableLog = !enableLog;
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Clear", GUILayout.MinWidth(minBtnWidth), GUILayout.MinHeight(minBtnHeight)))
            {
                ClearLog(showGroup);
            }
            if (GUILayout.Button("ClearAll", GUILayout.MinWidth(minBtnWidth), GUILayout.MinHeight(minBtnHeight)))
            {
                ClearAllLog();
            }

            GUILayout.Space(10);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            inputCommand = GUILayout.TextField(inputCommand, GUILayout.MinHeight(minBtnHeight / 2));
            if (GUILayout.Button("►", GUILayout.MaxWidth(minBtnWidth), GUILayout.MinHeight(minBtnHeight / 2)))
            {
                InvokeCommand(inputCommand);
            }
            GUILayout.EndHorizontal();
        }
        //inputCommand = GUILayout.TextField(inputCommand);

        if (showLog == 0)
        {
            if (GUILayout.Button("Console", GUILayout.MinWidth(minBtnWidth), GUILayout.MinHeight(minBtnHeight)))
            {
                showLog++;
            }
        }
        else
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("▲", GUILayout.MinWidth(minBtnWidth), GUILayout.MinHeight(minBtnHeight)))
            {
                showLog--;
                if (showLog > 3)
                {
                    showLog = 0;
                }
            }
            if (GUILayout.Button("▼", GUILayout.MinWidth(minBtnWidth), GUILayout.MinHeight(minBtnHeight)))
            {
                showLog++;
                if (showLog > 3)
                {
                    showLog = 0;
                }
            }
            GUILayout.EndHorizontal();
        }



        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
        #endif
    }
Пример #5
0
    /// <summary>
    /// Вывести сообщение в GUI консоль. Создается при первом обращении.
    ///
    /// </summary>
    /// <param name="message">Сообщение - любой обьект унаследованный от object</param>
    /// <param name="group">Название вкладки в которую выводится сообщение. Создает если ее нет</param>
    /// <param name="type">Тип сообщение для фильтрации по умолчанию Log</param>
    /// <param name="position">В какой строке консоли вывести сообщение. -1 -выводится на следующей строке</param>
    /// <param name="color">Цвет сообщения в консоле по умолчанию цвет соответствует типу</param>
    public static void Log(object message, string group, LogType type, int position, Color color)
    {
#if TEST_VERSION
#if UNITY_EDITOR
        if (group.Equals("General"))
        {
            switch (type)
            {
            case LogType.Error:
                Debug.LogError(message);
                break;

            case LogType.Warning:
                Debug.LogWarning(message);
                break;

            default:
                Debug.Log(message);
                break;
            }
            return;
        }
        #endif
        #if UNITY_STANDALONE || UNITY_IOS || UNITY_ANDROID
        #endif
        if (instance == null)
        {
            Init();
        }
        if (color == (Color)Vector4.zero)
        {
            color = instance.GetColorFromType(type);
        }

        if (!instance.lineDictionary.ContainsKey(group))
        {
            instance.lineDictionary.Add(group, new List <DebugMessageLine> ());
            if (instance.showGroup == null)
            {
                instance.showGroup = group;
            }
        }
        if (position != -1)
        {
            DebugMessageLine newLine = new DebugMessageLine();
            newLine.message   = message.ToString();
            newLine.color     = color;
            newLine.count     = 1;
            newLine.type      = type;
            newLine.deltaTime = instance.averageDeltaTime;

            for (int i = instance.lineDictionary[group].Count - 1; i < position; i++)
            {
                instance.lineDictionary[group].Add(new DebugMessageLine());
            }
            instance.lineDictionary[group][position] = newLine;
        }
        else
        if (!instance.ChkEquals(message, color, group))
        {
            DebugMessageLine newLine = new DebugMessageLine();
            newLine.message   = message.ToString();
            newLine.color     = color;
            newLine.count     = 1;
            newLine.type      = type;
            newLine.deltaTime = instance.averageDeltaTime;

            instance.lineDictionary[group].Add(newLine);


            if (instance.lineDictionary[group].Count > instance.messageCount)
            {
                instance.lineDictionary[group].RemoveAt(0);
            }
        }
        else
        {
        }
        #endif
    }