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参数

Returns

bool - The selected state of the toggle.

返回布尔类型 - 开关按钮的选择状态。

Description描述

Make a toggle.

制作一个开关按钮。

EditorGUI.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();
	}
}
Page last updated: 2011-6-22