EditorGUI.Toggle 开关按钮
static function Toggle (position : Rect, value : bool) : bool
static function Toggle (position : Rect, label : string, value : bool) : bool
static function Toggle (position : Rect, label : GUIContent, value : bool) : bool
Parameters参数
- positionRectangle on the screen to use for the toggle.
屏幕上开关按钮使用的矩形区域 - labelOptional label in front of the toggle.
开关按钮前的可选标签 - valueThe shown state of the toggle.
开关按钮的状态
Returns
bool - The selected state of the toggle.
返回布尔类型 - 开关按钮的选择状态。
Description描述
Make a toggle.
制作一个开关按钮。
Toggle control in an Editor Window.
在编辑器窗口开关控制。
// Use a toggle button to show/hide a button that can close the window.//用一个开关按钮来 显示/隐藏 一个能关闭窗口的按钮class EditorGUIToggle extends EditorWindow {var showClose : boolean = true;@MenuItem("Examples/EditorGUI Toggle usage")static function Init() {var window = GetWindow(EditorGUIToggle);window.Show();}function OnGUI() {showClose = EditorGUI.Toggle(Rect(0,5,position.width,20),"Show Close Button",showClose);if(showClose)if(GUI.Button(Rect(0, 25, position.width, 100),"Close Window!"))this.Close();}}