EditorGUILayout.Foldout 折叠标签

static function Foldout (foldout : bool, content : string, style : GUIStyle = EditorStyles.foldout) : bool
static function Foldout (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.

这通常用于创建树或类似的文件夹结构,如果父物体折叠打开,才显示子物体。

EditorGUILayout.Foldout 折叠标签

Create a foldable menu that hides/shows the selected transform.
创建可折叠菜单,隐藏/显示选择的变换。

// 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 FoldoutUsage extends EditorWindow {

	var showPosition : boolean = true;
	var status : String = "Select a GameObject";
	@MenuItem("Examples/Foldout Usage")
	static function Init() {
		var window = GetWindow(FoldoutUsage);
		window.Show();
	}

	function OnGUI() {
		showPosition = EditorGUILayout.Foldout(showPosition, status);
		if(showPosition)
			if(Selection.activeTransform) {
				Selection.activeTransform.position =
					EditorGUILayout.Vector3Field("Position", Selection.activeTransform.position);
				status = Selection.activeTransform.name;
			}

		if(!Selection.activeTransform) {
			status = "Select a GameObject";
			showPosition = false;
		}
	}
	function OnInspectorUpdate() {
		this.Repaint();
	}
}
最后修改:2011年7月14日 Thursday 18:38

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。