GUILayout.Space 留空

static function Space (pixels : float) : void

Description描述

Insert a space in the current layout group.

在当前层组插入空白。

The direction of the space is dependent on the layout group you're currently in when issuing the command. If in a vertical group, the space will be vertical: Note: This will override the GUILayout.ExpandWidth and GUILayout.ExpandHeight

空白的方向取决于你当前层组。如果是在垂直组,空白将是垂直的。注意:这将重写GUILayout.ExpandWidthGUILayout.ExpandHeight

GUILayout.Space 留空

Space of 20px between two buttons.
两个按钮之间的20像素空距。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
		void OnGUI() {
		GUILayout.Button("I'm the first button");
		GUILayout.Space(20);
		GUILayout.Button("I'm a bit further down");
	}
}
function OnGUI () {
	GUILayout.Button ("I'm the first button");

	// Insert 20 pixels of space between the 2 buttons.
	//在2个按钮直接插入20像素的空白
	GUILayout.Space (20);

	GUILayout.Button ("I'm a bit further down");
}

In horizontal groups, the pixels are measured horizontally:

在水平组,像素是相对于水平方向:

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void OnGUI() {
		GUILayout.Button("I'm the first button");
		GUILayout.Space(20);
		GUILayout.Button("I'm the second button");
	}
}
function OnGUI () {
	GUILayout.Button ("I'm the first button");

	// Insert 20 pixels of space between the 2 buttons.
	//在2个按钮直接插入20像素的空白
	GUILayout.Space (20);

	GUILayout.Button ("I'm the second button");
}
最后修改:2011年6月14日 Tuesday 14:45

本脚本参考基于Unity 3.4.1f5

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