unity3d 在调试安卓,有方法在手机上(屏幕上)直接显示报错信息吗?
1个回答
展开全部
可以,请使用以下脚本,拖到任意一个GO上即可
public class ErrorDisplay : MonoBehaviour
{
internal void OnEnable()
{
Application.RegisterLogCallback(HandleLog);
}
internal void OnDisable()
{
Application.RegisterLogCallback(null);
}
private string m_logs;
/// <summary>
///
/// </summary>
/// <param name="logString">错误信息</param>
/// <param name="stackTrace">跟踪堆栈</param>
/// <param name="type">错误类型</param>
void HandleLog(string logString, string stackTrace, LogType type)
{
m_logs += logString + "\n";
}
public bool Log;
private Vector2 m_scroll;
internal void OnGUI()
{
if (!Log)
return;
m_scroll = GUILayout.BeginScrollView(m_scroll);
GUILayout.Label(m_logs);
GUILayout.EndScrollView();
}
}
public class ErrorDisplay : MonoBehaviour
{
internal void OnEnable()
{
Application.RegisterLogCallback(HandleLog);
}
internal void OnDisable()
{
Application.RegisterLogCallback(null);
}
private string m_logs;
/// <summary>
///
/// </summary>
/// <param name="logString">错误信息</param>
/// <param name="stackTrace">跟踪堆栈</param>
/// <param name="type">错误类型</param>
void HandleLog(string logString, string stackTrace, LogType type)
{
m_logs += logString + "\n";
}
public bool Log;
private Vector2 m_scroll;
internal void OnGUI()
{
if (!Log)
return;
m_scroll = GUILayout.BeginScrollView(m_scroll);
GUILayout.Label(m_logs);
GUILayout.EndScrollView();
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询