When customizing the editor window in unity, you can use variables to control when you want to automatically load and display some information when you open a window. However, after the code is modified, unity recompile the code, the window that has been opened, and no longer automatically reloads the information. Here you can use 静态变量 and 静态构造函数 , to perform a reset load.
The sample code is as follows:
Public classpreviewparticlewindow:editorwindow{[MenuItem ("Previewparticle",false, -)]Private Static void Init() {getwindow<previewparticlewindow> (); }StaticPreviewparticlewindow () {autoLoad =true; }Private Static BOOLAutoLoad =true;voidOngui () {if(AutoLoad) {//refreshloadparticle ();AutoLoad =false; } }}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Unity Static Constructors Special use