Unity 日志输出

日志文件存放路径
Mac OS X ~/Library/Logs/Unity/Editor.log

Windows C:\Users\username\AppData\Local\Unity\Editor\Editor.log

编辑器下点击OpenEditorLog
在这里插入图片描述

移动端,可以通过回调函数操作文件自己实现

     Application.logMessageReceived += XPLog;
 void XPLog(string condition,string stackTrace, LogType logtype)
    {
        Debug.Log($"回调函数condition={condition},stackTrace={stackTrace},logtype={logtype}");
    }

关闭输出,正式发布时可以调用
Debug.unityLogger.logEnabled = false;

Debug.Assert();
如果满足条件才会输出,但不会方法返回

断言Assert
断言是一种检查条件的方法。如果条件为真,则方法返回并继续执行。如果发生意外情况并且不满足条件中的假设,则会打印一条消息,显示调用堆栈和可选的用户指定消息
使用UnityEngine.Assertions.Assert的断言方法,当满足条件就会返回方法,可以选择是否要输出

猜你喜欢

转载自blog.csdn.net/weixin_44806700/article/details/120707496
今日推荐