Skip to content

Instantly share code, notes, and snippets.

@klkucan
Last active October 17, 2017 02:26
Show Gist options
  • Save klkucan/361a2738dcb6af5fff950f0f5328d9bd to your computer and use it in GitHub Desktop.
Save klkucan/361a2738dcb6af5fff950f0f5328d9bd to your computer and use it in GitHub Desktop.
UnityClearConsole in edtior
[MenuItem("Tools/ClearConsole")]
private static void ClearConsole()
{
#if UNITY_5
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);
#elif UNITY_2017
var assembly = Assembly.GetAssembly(typeof(SceneView));
var type = assembly.GetType("UnityEditor.LogEntries");
var method = type.GetMethod("Clear");
method.Invoke(new object(), null);
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment