[总结]Unity Console面板的问题汇总

1.Console面板双击无法定位问题

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

console

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));

占位符

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值