unity4.x Code Auto Clear Console Log

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.