- BeginArea
- BeginHorizontal
- BeginScrollView
- BeginVertical
- Box
- Button
- EndArea
- EndHorizontal
- EndScrollView
- EndVertical
- ExpandHeight
- ExpandWidth
- FlexibleSpace
- Height
- HorizontalScrollbar
- HorizontalSlider
- Label
- MaxHeight
- MaxWidth
- MinHeight
- MinWidth
- PasswordField
- RepeatButton
- SelectionGrid
- Space
- TextArea
- TextField
- Toggle
- Toolbar
- VerticalScrollbar
- VerticalSlider
- Width
- Window
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参数
-
textText to display on the button.
显示在按钮上的文本 -
imageTexture to display on the button.
显示在按钮上的纹理 -
contentText, image and tooltip for this button.
用于该按钮的文本、图片和工具提示 -
styleThe style to use. If left out, the button style from the current GUISkin is used.
使用的样式。如果不使用,该按钮使用当前的GUISkin皮肤 -
optionsAn optional list of layout options that specify extra layouting properties. Any values passed in here will override settings defined by the style.
布局选项指定额外布局属性的一个可选列表。这里传递任意值都将覆盖由style定义的设置。
参考: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
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。
按下按钮不放,这个按钮会持续反复执行代码。
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");
}
}