Example #1
0
        public void LogMessage(string word, eLogMessageType logMessageType, bool isOther)
        {
            string logtext = "(" + fpsCount + ")" + word + "\n";

            if (isOther)
            {
                if (debugText2.text.Length >= maxTextLength)
                {
                    debugText2.text = "";
                }
                debugText2.text += logtext;
                scrollRect2.verticalNormalizedPosition = 0;
            }
            else
            {
                if (debugText1.text.Length >= maxTextLength)
                {
                    debugText1.text = "";
                }
                debugText1.text += logtext;
                scrollRect1.verticalNormalizedPosition = 0;
            }
            Debug.Log(timeCount + "-" + word);
            //Canvas.ForceUpdateCanvases();
        }
Example #2
0
        public void LogMessage(string word, eLogMessageType logMessageType, bool isOther)
        {
            string     logtext    = "(" + fpsCount + ")" + word + "\n";
            Text       debugText  = isOther ? debugText2 : debugText1;
            ScrollRect scrollRect = isOther ? scrollRect2 : scrollRect1;
            int        overText   = debugText.text.Length - maxTextLength;

            if (overText > 0)
            {
                string[]       messages     = debugText.text.Split(SPLIT, System.StringSplitOptions.None);
                Stack <string> messageStack = new Stack <string>();
                int            lengthCount  = 0;
                for (int i = messages.Length - 1; i >= 0; i--)
                {
                    lengthCount += messages[i].Length;
                    if (lengthCount < maxTextLength)
                    {
                        messageStack.Push(messages[i]);
                    }
                    else
                    {
                        break;
                    }
                }
                debugText.text = "";
                foreach (string str in messageStack)
                {
                    debugText.text += str;
                }
                //debugText2.text = debugText2.text.Substring(overText+5);
                //debugText2.text = "";
            }
            debugText.text += logtext;
            scrollRect.verticalNormalizedPosition = 0;
            if (logMessageType == eLogMessageType.ERROR)
            {
                Debug.LogError(timeCount + "-" + word);
                if (BattleManager.Instance.ShowErrorMessage)
                {
                    MainManager.Instance.WindowConfigMessage("<color=#FF0000>" + word + "</color>", null, null);
                }
            }
            else
            {
                Debug.Log(timeCount + "-" + word);
            }
            //Canvas.ForceUpdateCanvases();
        }