将Unity的Debug.Log输出到屏幕

匿名 (未验证) 提交于 2019-12-03 00:26:01
using UnityEngine;  class TestConsole : MonoBehaviour {     void OnEnable()     {         Application.logMessageReceived += HandleLog;     }      void OnDisable()     {         Application.logMessageReceived -= HandleLog;     }      void OnDestroy()     {         Application.logMessageReceived -= HandleLog;     }      /// <summary>     /// Records a log from the log callback.     /// </summary>     /// <param name="message">Message.</param>     /// <param name="stackTrace">Trace of where the message came from.</param>     /// <param name="type">Type of message (error, exception, warning, assert).</param>     void HandleLog(string message, string stackTrace, LogType type)     {         if (Application.isEditor)             return;         if (type == LogType.Exception || type == LogType.Error)         {             NGUIDebug.Log(type.ToString() + ":" + message + "\n stack: " + stackTrace);         }         else if (type == LogType.Log)         {             NGUIDebug.Log(message);         }     } }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!