在编辑器模式下运行:在需要运行的脚本加上[ExecuteInEditMode]
清空编辑器控制台日志
void ClearLog()
{
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetAssembly(typeof(UnityEditor.SceneView));
System.Type logEntries = assembly.GetType("UnityEditor.LogEntries");
System.Reflection.MethodInfo clearConsoleMethod = logEntries.GetMethod("Clear");
clearConsoleMethod.Invoke(new object(), null);
}
在需要调用时调用即可
参考链接:(213条消息) Unity在编辑器下清空控制台中的Debug.Log()信息_先生沉默先的博客-优快云博客_unity 清空log