GUILayout.Button 按钮

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

Parameters参数

Returns

bool - /true/ when the users clicks the button

返回布尔类型,当用户点击按钮时返回true。

Description描述

Make a single press button. The user clicks them and something happens immediately.

创建一个单次按钮。当用户点击按钮会立即发生一些事件。

GUILayout.Button 按钮

Buttons in the Game View.
在游戏视图中的按钮。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public Texture tex;
	void OnGUI() {
		if (!typeof(tex))
			Debug.LogError("No texture found, please assign a texture on the inspector");

		if (GUILayout.Button(tex))
			Debug.Log("Clicked the image");

		if (GUILayout.Button("I am a regular Automatic Layout Button"))
			Debug.Log("Clicked Button");

	}
}
// Draws a button with an image and a button with text
//绘制一个带有图片的按钮和一个带有文本的按钮
var tex : Texture;
function OnGUI() {
	if(!tex) {
		Debug.LogError("No texture found, please assign a texture on the inspector");
	}

	if(GUILayout.Button (tex)) {
		Debug.Log("Clicked the image");
	}
	if(GUILayout.Button ("I am a regular Automatic Layout Button")) {
		Debug.Log("Clicked Button");
	}
}
Page last updated: 2011-6-14