Unity Editor Extension texture display selection box

Source: Internet
Author: User

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

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.