using System.Collections; using System.Collections.Generic; using UnityEngine; public class DebugLogManager : MonoBehaviour { [SerializeField] private TextMesh mText; private List mLogList = new List(); private DebugOutputManager mDebugOutputManagder;//专门做日志输出的 void Start () { Application.logMessageReceived += MsgReceivedLog; mDebugOutputManagder = new DebugOutputManager(); if(CDebug.IsDebug == false) { mText.gameObject.SetActive(false); } if(mText != null) mText.text = ""; } void OnDestroy() { Application.logMessageReceived -= MsgReceivedLog; } private const int MAX_COUNT = 20; private void MsgReceivedLog( string logStr, string sTrace, LogType lType ) { if(mText == null) { //不存在 或者应用已经关闭了 return; } if (GamePlayerData.Instance.isDebugAccount) mLogList.Add (new DebugLog(logStr, sTrace, lType)); mText.text = ""; for (int i = Mathf.Max(0, mLogList.Count - MAX_COUNT); i < mLogList.Count; i++) { mText.text = mText.text + "\n" + mLogList[i].ToString(); } } }