Effect
Can be executed in editor mode, but can also be performed in runtime mode
function : When making some functions in editor, it is often necessary to manually click the clear of the console window to clear the log, this method can be easily after the script compiled automatically clear the log
[Initializeonload][executeineditmode] Public Partial class csimulateenv:monobehaviour{ static csimulateenv () { clearlog (); }}
The code is as follows:
usingSystem.Reflection;usingUnityengine; Public classcleartest:monobehaviour{//Use this for initialization voidStart () {clearlog (); } voidOngui () {if(Guilayout.button ("Clear") ) {clearlog (); } } Public voidClearlog () {varAssembly = assembly.getassembly (typeof(Unityeditor.activeeditortracker)); varType = assembly. GetType ("unityeditorinternal.logentries"); varmethod = Type. GetMethod ("Clear"); Method. Invoke (New Object(),NULL); }}
Reference from: http://answers.unity3d.com/questions/10580/editor-script-how-to-clear-the-console-output-wind.html
unity4.x Code Auto Clear Console Log