Editor-script: How to clear the "console"-output window ?

Hi, im working on a small editor-script and want to know, how can i clear the console/output window of debug-messages?

Ive created an editor-script which gives me output to the console while im working in edit-mode. I know about the "clear & clear on play"-button, but i want to add clearing the console-output with an shortcut, without clicking the clear button manually. Is that possible?

Thanks for your time and help.

God knows why these things aren't exposed. Here it is using reflection:

public static void ClearLog()
{
    Assembly assembly = Assembly.GetAssembly(typeof(SceneView));

    Type type = assembly.GetType("UnityEditor.LogEntries");
    MethodInfo method = type.GetMethod("Clear");
    method.Invoke(new object(), null);
}

If you want to do anything similar, grab Red Gate's .NET Reflector, find the method you're after and swap some stuff around to fire it.

After George's answer, I found the need to write it in JavaScript. Here's the equivalent snippet:

import System;
import System.Reflection;

public static function ClearLog()
{
    var assembly : Assembly = Assembly.GetAssembly(typeof(SceneView));
    var type : Type = assembly.GetType("UnityEditor.LogEntries");
    var method : MethodInfo = type.GetMethod("Clear");
    var object = new Object();
    method.Invoke(object, null);
}

On unity 3.2 you need to do that now:

Assembly assembly = Assembly.GetAssembly(typeof(Macros));
            Type type = assembly.GetType("UnityEditorInternal.LogEntries");
            MethodInfo method = type.GetMethod ("Clear");
            method.Invoke (new object (), null);

for 4.3.4, it’s “UnityEditorInternal.LogEntries” in assembly which contains “UnityEditor.ActiveEditorTracker”.


    public static 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);
    }

don’t forget to add 3 using sentences,it took me a little time to make it work.

using System.Reflection;
using UnityEditor;
using System;

For Unity 5.5+ they’ve renamed it to UnityEditorInternal.LogEntries (the type name you have to use with reflection):

public static void ClearDeveloperConsole() {
	Assembly assembly = Assembly.GetAssembly (typeof(SceneView));
	Type logEntries = assembly.GetType ("UnityEditorInternal.LogEntries");
	MethodInfo clearConsoleMethod = logEntries.GetMethod ("Clear");
	clearConsoleMethod.Invoke (new object (), null);
}