标签:style blog http color io ar for strong sp
可在Editor模式下执行,当然也可以Runtime模式下执行
作用:当在制作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
Unity4.x Code Auto Clear Console Log
标签:style blog http color io ar for strong sp
原文地址:http://www.cnblogs.com/zhaoqingqing/p/4026812.html