GUILayout.RepeatButton 重复按钮

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

Parameters参数

Returns

bool - /true/ when the holds down the mouse

返回布尔类型,当用户按住鼠标时返回true。

Description描述

Make a repeating button. The button returns true as long as the user holds down the mouse

创建一个重复按钮。当用户点击按钮会立即发生一些事件。只要用户按住鼠标,按钮返回true。

按下按钮不放,这个按钮会持续反复执行代码。

GUILayout.RepeatButton 重复按钮

Repeat 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.RepeatButton(tex))
			Debug.Log("Clicked the image");

		if (GUILayout.RepeatButton("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.RepeatButton (tex)) {
		Debug.Log("Clicked the image");
	}
	if(GUILayout.RepeatButton ("I am a regular Automatic Layout Button")) {
		Debug.Log("Clicked Button");
	}
}
Page last updated: 2011-6-14