开发中便于观察Console的信息,常常会用到清理控制太的功能,而Unity并没有开放出来,在其他地方看到的用反射的方法调用:
- [MenuItem("XBDebug/ClearConsole %#c", false, 37)]
- public static void ClearConsole()
- {
- // This simply does "LogEntries.Clear()" the long way:
- var logEntries = System.Type.GetType("UnityEditorInternal.LogEntries,UnityEditor.dll");
- var clearMethod = logEntries.GetMethod("Clear", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
- clearMethod.Invoke(null, null);
- }
暂停:
Debug.Pause();