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