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();
    }
}
相关推荐
敲代码的瓦龙1 分钟前
操作系统相关的一些问题总结
linux·c语言·开发语言
牛奔4 分钟前
php 8.2 配置安装php-zbarcode扩展
android·开发语言·php
Fcy64819 分钟前
C++ 模版(进阶)(含array解析)
开发语言·c++·stl·array·模版
OKkankan25 分钟前
多态概念及使用
开发语言·数据结构·c++·算法
hudawei99625 分钟前
kotlin协程编译成Android字节码后是什么样的
android·开发语言·kotlin
小周码代码36 分钟前
js 数字金额转为大写 js 金额转大写
开发语言·前端·javascript·js工具
行走在电子领域的工匠38 分钟前
台达ST:自定义串行通讯传送与接收指令COMRS程序范例五
开发语言·台达plc·st语言编程·串口自定义协议
BillKu1 小时前
html2pdf.js使用与配置详解
开发语言·javascript·ecmascript
n***s9091 小时前
ThinkPHP和PHP的区别
开发语言·php
code bean1 小时前
【C++】全局函数和全局变量
开发语言·c++·c#