- 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.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参数
-
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 users clicks the button
返回布尔类型,当用户点击按钮时返回true。
Description描述
Make a single press button. The user clicks them and something happens immediately.
创建一个单次按钮。当用户点击按钮会立即发生一些事件。
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");
}
}