EditorGUI.Foldout 折叠标签

static function Foldout (position : Rect, foldout : bool, content : string, style : GUIStyle = EditorStyles.foldout) : bool
static function Foldout (position : Rect, foldout : bool, content : GUIContent, style : GUIStyle = EditorStyles.foldout) : bool

Parameters参数

Returns

bool - The foldout state selected by the user. If true, you should render sub-objects.

返回布尔类型,用户选择的折叠状态,如果为真,应该渲染子对象。

Description描述

Make a label with a foldout arrow to the left of it.

制作一个左侧带折叠箭头的标签。

This is useful for creating tree or folder like structures where child objects are only shown if the parent is folded out.

这对于建立一个树或者文件夹很有用,就像一个结构,子对象只有在父对象展开时才显示

EditorGUI.Foldout 折叠标签

Foldout in an Editor Window.
在编辑器窗口中的折叠标签。

// Create a foldable menu that hides/shows the selected transform
// position.
//创建一个可折叠菜单 隐藏/显示 选择的变换位置
// if no Transform is selected, the Foldout item will be folded until
// a transform is selected.
//如果没有变换被选中,折页将被折叠,直到变换被选择
class EditorGUIFoldout extends EditorWindow {
	var showPosition : boolean = true;
	var status : String = "Select a GameObject";
	@MenuItem("Examples/Foldout Usage")
	static function Init() {
		var window = GetWindow(EditorGUIFoldout);
		window.position = Rect(0, 0, 150, 60);
		window.Show();
	}

	function OnGUI() {
		showPosition = EditorGUI.Foldout(Rect(3,3,position.width-6,15),showPosition, status);
		if(showPosition)
			if(Selection.activeTransform) {
				Selection.activeTransform.position =
					EditorGUI.Vector3Field(Rect(3,25,position.width -6 ,40),
						"Position",
						Selection.activeTransform.position);
				status = Selection.activeTransform.name;
		}
		if(!Selection.activeTransform) {
			status = "Select a GameObject";
			showPosition = false;
		}
	}
	function OnInspectorUpdate() {
		this.Repaint();
	}
}
Page last updated: 2011-6-23