Unity全局日志

注释

在打包完成了测试不方便,我们可以把打印信息存在文本里,然后可以再运行打包程序的时候可以查看

cpp 复制代码
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;


public class DebugToCall
{
    public static string path = "D:\\Log.txt";

    public static void Log(string log)
    {
        FileStream file;
        if (!File.Exists(path))
        {
            file = File.Create(path);
        }
        else
        {
            file = File.Open(path,FileMode.Open);
        }

        file.Dispose();
        UnityEngine.Debug.Log(log);
        File.AppendAllText(path, log + "\r", Encoding.UTF8);
        file.Close();
    }
}
相关推荐
John Song2 小时前
Python创建虚拟环境的方式对比与区别?
开发语言·python
搞程序的心海2 小时前
Python面试题(一):5个最常见的Python基础问题
开发语言·python
Swift社区5 小时前
如果今天重新做 Claw,会用什么技术
游戏·unity
MediaTea8 小时前
Python:collections.Counter 常用函数及应用
开发语言·python
LawrenceLan8 小时前
37.Flutter 零基础入门(三十七):SnackBar 与提示信息 —— 页面反馈与用户交互必学
开发语言·前端·flutter·dart
李昊哲小课9 小时前
Python json模块完整教程
开发语言·python·json
易醒是好梦9 小时前
Python flask demo
开发语言·python·flask
Tatalaluola9 小时前
3DGS高斯泼溅渲染简单理解
3d·unity·三维重建