static function RepeatButton (position : Rect, text : String) : bool
static function RepeatButton (position : Rect, image : Texture) : bool
static function RepeatButton (position : Rect, content : GUIContent) : bool
static function RepeatButton (position : Rect, text : String, style : GUIStyle) : bool
static function RepeatButton (position : Rect, image : Texture, style : GUIStyle) : bool
static function RepeatButton (position : Rect, content : GUIContent, style : GUIStyle) : bool
bool - true when the users clicks the button
当用户点击按钮的时候返回true。
Description描述
Make a button that is active as long as the user holds it down.
创建一个按钮,只要用户按着不放,将一直被激活。
从按下按钮到释放按钮的时间内重复引发其 Click 事件的控件,也就是说它将连续不停的发送点击事件。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public Texture btnTexture;
void OnGUI() {
if (!typeof(btnTexture)) {
Debug.LogError("Please assign a texture on the inspector");
return;
}
if (GUI.RepeatButton(new Rect(10, 10, 50, 50), btnTexture))
Debug.Log("Clicked the button with an image");
if (GUI.RepeatButton(new Rect(10, 70, 50, 30), "Click"))
Debug.Log("Clicked the button with text");
}
}
var btnTexture : Texture;
function OnGUI() {
if (!btnTexture) {
Debug.LogError("Please assign a texture on the inspector");
return;
}
if (GUI.RepeatButton(Rect(10,10,50,50),btnTexture))
Debug.Log("Clicked the button with an image");
if (GUI.RepeatButton(Rect(10,70,50,30),"Click"))
Debug.Log("Clicked the button with text");
}