Http://www.unity Bull. com/thread-25490-1-1.html
Http://www.unity Bull. com/m/script/editorguilayout.enumpopup.html
Editorguilayout.enumpopup Enumeration Popup Selection Menu
static functionEnumpopup(selected: System.Enum,params Options: guilayoutoption[]): System.Enum
static functionEnumpopup(selected: System.Enum,style: Guistyle,params Options: guilayoutoption[]): System.Enum
static functionEnumpopup(label: String,selected: System.Enum,params Options: guilayoutoption[]): System.Enum
static functionEnumpopup(label: String,selected: System.Enum,style: Guistyle,params Options: guilayoutoption[]): System.Enum
static functionEnumpopup(label: Guicontent,selected: System.Enum,params Options: guilayoutoption[]): System.Enum
static functionEnumpopup(label: Guicontent,selected: System.Enum,style: Guistyle,params Options: guilayoutoption[]): System.Enum
ParametersParameters
- label Optional label in front of the field. Optional label in front of the field.
- selected The enum option the field shows.
Enumeration display field options
- style Optional Guistyle. Optional styles
- Options An optional list of layout options, specify extra layouting properties. Any values passed in here would override settings defined by the style. See Also:GUILayout.Width, Guilayout.height, Guilayout.minwidth,guilayout.maxwidth, Guilayout.minheight, Guilayout.maxheight, Guilayout.expandwidth, Guilayout.expandheight
Specifies an optional list of additional layout properties. Passing any value here overrides the settings defined by the style.
Returns
System.enum-the Enum option that have been selected by the user.
Returns the enumeration option for System.Enum, which is selected by the user.
Description Description
Make an enum popup selection field.
Make an enumeration popup selection field.
Takes the currently selected enum value as a parameter and returns the Enum value selected by the user.
Takes the currently selected enumeration value as a parameter and returns the enumeration value selected by the user.
Create a primitive depending on the option selected.
Create a basic object, depending on the option selected by the user
//creates an instance of a primitive depending on the option selected by the user.//create an instance of a base object, depending on the option selected by the userenumOPTIONS {CUBE=0, SPHERE=1, PLANE=2}classEditorguilayoutenumpopup extends Editorwindow {varop:options; @MenuItem ("examples/editor guilayout Enum Popup usage") Staticfunction Init () {varwindow =GetWindow (Editorguilayoutenumpopup); Window. Show (); } function Ongui () {op= Editorguilayout.enumpopup ("Primitive to create:", op); if(Guilayout.button ("Create") ) instantiateprimitive (OP); } function Instantiateprimitive (op:options) {Switch(OP) { CaseOPTIONS. CUBE:varCube:gameobject =gameobject.createprimitive (Primitivetype.cube); Cube.transform.position=Vector3.zero; Break; CaseOPTIONS. SPHERE:varSphere:gameobject =gameobject.createprimitive (Primitivetype.sphere); Sphere.transform.position=Vector3.zero; Break; CaseOPTIONS. PLANE:varPlane:gameobject =gameobject.createprimitive (Primitivetype.plane); Plane.transform.position=Vector3.zero; Break; default: Debug.logerror ("Unrecognized Option"); Break; } }}
Editorguilayout.enumpopup Enumeration Popup Selection Menu