[总结] Unity Console面板的问题汇总
1.Console面板双击无法定位问题
点击Console面板右上角设置,选择Stack Trace Logging(堆栈追踪日志),选择无法定位的输出日志类型或者All,设置ScriptOnly,如下图,即可解决。其他的设置可以自行了解。

2.关闭Debug输出日志信息
程序发布的时候不需要输出日志信息,可以选择关闭。
- 5.3及以上版本的Unity提供了运行时关闭Debug的API:Debug.unityLogger.logEnabled = false;
- 旧版本的解决方法可以参考雨松老师的博客(链接)。
3.Debug颜色调试
- 默认颜色
Debug.Log("<color=red>红色</color>");
Debug.Log("<color=orange>橙色</color>");
Debug.Log("<color=yellow>黄色</color>");
Debug.Log("<color=green>绿色</color>");
Debug.Log("<color=blue>蓝色</color>");
Debug.Log("<color=purple>紫色</color>");
Debug.Log("<color=black>黑色</color>");
Debug.Log("<color=white>白色</color>");
Debug.Log("<color=grey>灰色</color>");

- 自定义颜色
HTML颜色编码工具:菜鸟教程(链接)
Debug.Log("<color=#FFC0CB>Pink</color>");
Debug.Log("<color=#FF69B4>HotPink</color>");
Debug.Log("<color=#FF1493>DeepPink</color>");

4.Debug占位符
int account = 1217;
string name = "great";
Debug.Log($"account: {account}, name: {name}");
Debug.Log(string.Format("account: {0}, name: {1}", account, name));


435

被折叠的 条评论
为什么被折叠?



