// private method
        // --------------
        void Awake()
        {
            _Instance = this;


            allQueue     = Queue.Synchronized(new Queue());
            logQueue     = Queue.Synchronized(new Queue());
            warningQueue = Queue.Synchronized(new Queue());
            errorQueue   = Queue.Synchronized(new Queue());

            vo            = new DebugLogVO();
            vo.logString  = "Register Log Callback !";
            vo.stackTrace = "";
            vo.logType    = LogType.Log;
            logQueue.Enqueue(vo);
            Application.RegisterLogCallback(CatchLogInfo);
        }
        private void CatchLogInfo(string logString, string stackTrace, LogType type)
        {
            if (preVO != null && preVO.logString == logString && preVO.stackTrace == stackTrace && type == type)
            {
                return;
            }

            vo            = new DebugLogVO();
            vo.logString  = logString;
            vo.stackTrace = stackTrace;
            vo.logType    = type;

            preVO = vo;

            switch (type)
            {
            case LogType.Log:
                logQueue.Enqueue(vo);
                break;

            case LogType.Warning:
                warningQueue.Enqueue(vo);
                break;

            case LogType.Assert:
            case LogType.Error:
            case LogType.Exception:
                errorQueue.Enqueue(vo);
                break;

            default:
                break;
            }

            allQueue.Enqueue(vo);
        }
        void Update()
        {
            if (debugLogType == DebugLogType.None)
            {
                return;
            }

            if (text.text.Split('\n').Length > 100)
            {
                return;
            }

            if (logQueue == null)
            {
                allQueue     = DebugLogManager.Instance.allQueue;
                logQueue     = DebugLogManager.Instance.logQueue;
                warningQueue = DebugLogManager.Instance.warningQueue;
                errorQueue   = DebugLogManager.Instance.errorQueue;
            }


            if (debugLogType == DebugLogType.All && allQueue.Count > 0)
            {
                vo = allQueue.Dequeue() as DebugLogVO;
            }
            else if (debugLogType == DebugLogType.Log && logQueue.Count > 0)
            {
                vo = logQueue.Dequeue() as DebugLogVO;
            }
            else if (debugLogType == DebugLogType.Warning && warningQueue.Count > 0)
            {
                vo = warningQueue.Dequeue() as DebugLogVO;
            }
            else if (debugLogType == DebugLogType.Error && errorQueue.Count > 0)
            {
                vo = errorQueue.Dequeue() as DebugLogVO;
            }
            else
            {
                vo = null;
            }

            if (vo == null)
            {
                return;
            }

            string stackTrace = vo.stackTrace;

            //		if(stackTrace.Length > 500)
            //		{
            //			string[] lines = stackTrace.Split('\n');
            //			stackTrace = "";
            //			for(int i = 0; i < (lines.Length < 20 ? lines.Length : 20); i ++)
            //			{
            //				stackTrace += lines[i] + "\n";
            //			}
            //		}

            text.text += "\n";
            switch (vo.logType)
            {
            case LogType.Log:
                text.text += string.Format("<color='{1}'>{0}</color>\n{2}", vo.logString, "#008844", stackTrace);
                break;

            case LogType.Warning:
                text.text += string.Format("<color='{1}'>{0}</color>\n{2}", vo.logString, "#ffa500", stackTrace);
                break;

            case LogType.Assert:
            case LogType.Error:
            case LogType.Exception:
                text.text += string.Format("<color='{1}'>{0}</color>\n{2}", vo.logString, "#ff0000", stackTrace);
                break;

            default:
                break;
            }
            //		text.text +=  "Length=" + text.text.Length.ToString() + " linenum="+ (text.text.Split('\n').Length);
            //		try{
            text.rectTransform.sizeDelta = new Vector2(text.rectTransform.sizeDelta.x, text.preferredHeight > (text.transform.parent as RectTransform).sizeDelta.y ? text.preferredHeight :  (text.transform.parent as RectTransform).sizeDelta.y);
            //		}
            //		catch()
            //		{warningQueue
            //
            //		}
        }
        public void SaveLog()
        {
            Queue allQueue = DebugLogManager.Instance.allQueue;

            string str = @"<html>
    <head>
    <meta charset='utf-8' />
    </head>

    <body>
    ";

            while (allQueue.Count > 0)
            {
                DebugLogVO vo = allQueue.Dequeue() as DebugLogVO;

                string stackTrace = vo.stackTrace;
                string logString  = vo.logString;
                //			logString = logString.Replace("<color=", "<font color=\"").Replace(">", "\">").Replace("</color\">", "</font>");

                switch (vo.logType)
                {
                case LogType.Log:
                    str += string.Format("<p><h3 style=\"color: {1}; \"><pre>[Log] {0}</pre></h3><br><pre>{2}</pre></p>", logString, "#008844", stackTrace);
                    break;

                case LogType.Warning:
                    str += string.Format("<p><h2 style=\"color: {1}; margin-bottom: 12px;\"><pre>[Warning] {0}</pre></h2><br><pre>{2}</pre></p>", logString, "#ffa500", stackTrace);
                    break;

                case LogType.Assert:
                case LogType.Error:
                case LogType.Exception:
                    str += string.Format("<p><h2 style=\"color: {1}; margin-bottom: 12px;\"><pre>[Error] {0}</pre></h2><br><pre>{2}</pre></p>", logString, "#ff0000", stackTrace);
                    break;

                default:
                    break;
                }
            }
            str += @"</body></html>";


            string filesPath = "/log.html";

            #if UNITY_EDITOR
            filesPath = Application.dataPath + "/../log.html";
            #elif UNITY_STANDALONE || UNITY_STANDALONE_OSX
            filesPath = Application.dataPath + "/log.html";
            #else
            filesPath = Application.persistentDataPath + "/log.html";
            #endif
            PathUtil.CheckPath(filesPath, true);
            if (File.Exists(filesPath))
            {
                File.Delete(filesPath);
            }
            FileStream   fs = new FileStream(filesPath, FileMode.CreateNew);
            StreamWriter sw = new StreamWriter(fs);
            sw.Write(str);
            sw.Close();
            fs.Close();

//            string url = "file:///" + filesPath;
            Debug.Log(filesPath);
//          Application.OpenURL(url);
        }