Auto Clear Unity Console Log
2024-09-11 10:29:30
功能
可以在Editor模式下执行,当然也可以Runtime模式下执行,自动清除 Console的log信息
功能需求
当在制作Editor的一些功能时,常常需要手动的点击Console窗口的Clear来清除日志,通过这个方法可以很方便的在脚本编译后自动清除日志
[InitializeOnLoad]
[ExecuteInEditMode]
public partial class CSimulateEnv : MonoBehaviour
{
static CSimulateEnv()
{
ClearLog();
}
}
示例代码
using System.Reflection;
using UnityEngine; public class ClearTest : MonoBehaviour
{
// Use this for initialization
void Start()
{
ClearLog();
} void OnGUI()
{
if (GUILayout.Button(" clear "))
{
ClearLog();
}
} public void ClearLog()
{
var assembly = Assembly.GetAssembly(typeof(UnityEditor.ActiveEditorTracker));
var type = assembly.GetType("UnityEditorInternal.LogEntries");
var method = type.GetMethod("Clear");
method.Invoke(new object(), null);
}
}
参考资料
http://answers.unity3d.com/questions/10580/editor-script-how-to-clear-the-console-output-wind.html
最新文章
- PHP-----文件系统的交互
- js 基础面试题
- 第二章 jQuery数组和字符串
- 分享一些App常用的模块
- WEB-INF&; 绝对路径vs相对路径
- hdu 2055
- python之类定义
- TI的AM3359的sd卡分区以及sd卡启动说明
- 关于atoi的实现
- java新手笔记6 示例for
- ​C语言数组作为函数参数
- windows下qtcreator添加ICE库文件
- ios开发之路十一(ARC forbids explicit message send of 'autorelease'错误)
- Ubuntu 忘记密码
- Codeforces Round #436 (Div. 2) E. Fire
- K:java中的hashCode和equals方法
- oracel 拆分字符串
- ArcGIS案例教程-通过点坐标生成矩形
- zigbee_蓝牙_wifi的比较与区别分析
- 1. github配置
热门文章
- 自定义XML动态配置程序
- IE浏览器中ajax使用缓存数据的问题
- 转载 BCS 的好文章 1 - 怎么创建和使用BCS
- vsphere vcenter server下安装ubuntu的vmwaretools
- 《C程序设计的抽象思维》1.9编程练习
- storyBoard配置错误导致崩溃 superview]: unrecognized selector...
- 大家一起和snailren学java-(二)一切都是对象
- 换新 iPhone 前要做的 9 件事
- Effective Java 21 Use function objects to represent strategies
- cxf数据压缩