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();
    }
}
相关推荐
2501_9409439121 小时前
体系课\ Python Web全栈工程师
开发语言·前端·python
rafael(一只小鱼)1 天前
AI运维开发平台学习
java·开发语言
b***74881 天前
C++在系统中的内存对齐
开发语言·c++
散峰而望1 天前
C++数组(三)(算法竞赛)
开发语言·c++·算法·github
4***14901 天前
C++在系统中的编译优化
开发语言·c++
田姐姐tmner1 天前
Python切片
开发语言·python
oioihoii1 天前
C++程序执行起点不是main:颠覆你认知的真相
开发语言·c++
周杰伦fans1 天前
C# 中的**享元工厂**模式
开发语言·数据库·c#
u***u6851 天前
C++在系统中的异常处理
java·开发语言·c++
爱学测试的雨果1 天前
收藏!软件测试面试题
开发语言·面试·职场和发展