Unity Editor Extension custom form

Source: Internet
Author: User

I was curious to see Unity also customizing pop-up forms. So I went to the internet to look for articles. If you want to customize the form, you need to put the class under the Editor folder.

The code is as follows:

usingUnityengine; usingUnityeditor;  Public classMyeditor:editorwindow {[MenuItem ("Gameobject/window")]            Static voidAddWindow () {Rect WR=NewRect (0,0, -, -); Myeditor window= (myeditor) editorwindow.getwindowwithrect (typeof(Myeditor), WR,true,"Plate Face"); }            Private stringtext; PrivateTexture Texture;  Public voidAwake () {Texture= Resources.load ("1") asTexture; }            voidOngui () {text= Editorguilayout.textfield ("Enter text", text); if(Guilayout.button ("Turn on Notifications", Guilayout.width ( $)))                {                     This. Shownotification (NewGuicontent ("This is a Notification")); }                if(Guilayout.button ("Turn off Notifications", Guilayout.width ( $)))                {                    //close the notification bar                     This.                RemoveNotification (); } Editorguilayout.labelfield ("The position of the mouse in the window", Event.current.mousePosition.ToString ()); Texture= Editorguilayout.objectfield ("Add a decal", Texture,typeof(Texture),true) asTexture; if(Guilayout.button ("Close Window", Guilayout.width ( $)))                {                    //Close Window                     This.                Close (); }            }            voidonfocus () {Debug.Log ("when the window gets the focus call once"); }            voidOnLostFocus () {Debug.Log ("called once when the window loses focus"); }            voidOnhierarchychange () {Debug.Log ("called once when any object in the hierarchy view has changed"); }            voidOnprojectchange () {Debug.Log ("called once when a resource in Project view has changed"); }            voidoninspectorupdate () { This.            Repaint (); }            voidOnselectionchange () {foreach(Transform tinchselection.transforms) {Debug.Log ("Onselectionchange"+t.name); }            }            voidOnDestroy () {Debug.Log ("called when the window is closed"); }        }

1. There is no way to find out how to pass values between custom forms and components at the moment!

This article fixed link: http://www.xuanyusong.com/archives/2211

Reprint Please specify: Rain pine Momo April 15, 2013 Yu Yussong Momo Program Research Institute published

Unity Editor Extension custom form

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.