Button, RepeatButton

示例程序
说明生成按钮

用法

二者用法相同。不同在于 Button 生成常规意义的按钮,当鼠标在按钮上松开时函数返回 trueRepeatButton 则是只要鼠标在按下状态就始终返回 true

public static bool Button(Texture image, params GUILayoutOption[] options);
public static bool Button(string text, params GUILayoutOption[] options);
public static bool Button(GUIContent content, params GUILayoutOption[] options);
public static bool Button(Texture image, GUIStyle style, params GUILayoutOption[] options);
public static bool Button(string text, GUIStyle style, params GUILayoutOption[] options);
public static bool Button(GUIContent content, GUIStyle style, params GUILayoutOption[] options);

参数

text

区域内要显示的文字。

image

区域内要显示的图片。

content

区域内要显示的文本、图片或者小提示。

style

(可选)该区域的样式。

options

(可选)用于指定额外的布局属性,该参数将覆盖默认样式。

示例

private void OnSceneGUI () {
		Handles.BeginGUI ();
	
		if (GUILayout.Button ("Button")) {
				Debug.Log ("Button Clicked");
		}
	
		if (GUILayout.RepeatButton ("Repeat Button")) {
				Debug.Log ("Repeat Button Held");
		}
	
		Handles.EndGUI ();
}