When learning Ngui plugin, suddenly there is a question why is it that these properties can be selected by a pop-up window? The components I write myself can only be =.= using manual drag-and-drop mode.
Unity has developed the Component Inspector View extension API, and if we want to write plugins that are easy for others to use, use the editor extension API to make our components appear more ornate and easy to use
Texture pop-up selection box, select the image assignment:
1 components corresponding to 1 edit extenders, inherit editor must be left in the editor folder
MyComponent:
usingUnityengine;usingSystem.Collections; Public classMycomponent:monobehaviour {//do not let fields appear above the Inspector View[Serializefield]PrivateRect Rectvalue; [Serializefield]PrivateTexture Texture; PublicTexture Texture {Get{returnTexture;} Set{texture =value;} } PublicRect Rectvalue {Get{returnRectvalue;} Set{Rectvalue =value;} }}
Mycomponentedit Editor:
usingUnityengine;usingSystem.Collections;usingUnityeditor; [Customeditor (typeof(MyComponent))] Public classMycomponentedit:editor { Public Override voidOninspectorgui () {mycomponent edit=(mycomponent) target; Edit. Rectvalue= Editorguilayout.rectfield ("window coordinates", edit. Rectvalue); //The map properties are displayed in the Inspector view as a selection box, so that we choose the decalEdit. Texture = Editorguilayout.objectfield ("Add a decal", edit. Texture,typeof(Texture),true) asTexture; }}
This article fixed link: http://www.xuanyusong.com/archives/2202
Reprint Please specify: Rain pine Momo April 11, 2013 Yu Yussong Momo Program Research Institute published
Unity Editor Extension texture display selection box