GUI
- backgroundColor
- BeginGroup
- BeginScrollView
- Box
- BringWindowToBack
- BringWindowToFront
- Button
- changed
- color
- contentColor
- depth
- DragWindow
- DrawTexture
- enabled
- EndGroup
- EndScrollView
- FocusControl
- FocusWindow
- GetNameOfFocusedControl
- GUI
- HorizontalScrollbar
- HorizontalSlider
- Label
- matrix
- PasswordField
- RepeatButton
- ScrollTo
- SelectionGrid
- SetNextControlName
- skin
- TextArea
- TextField
- Toggle
- Toolbar
- tooltip
- UnfocusWindow
- VerticalScrollbar
- VerticalSlider
- Window
GUI.Button 按钮
static function Button (position : Rect, text : String) : bool
static function Button (position : Rect, image : Texture) : bool
static function Button (position : Rect, content : GUIContent) : bool
static function Button (position : Rect, text : String, style : GUIStyle) : bool
static function Button (position : Rect, image : Texture, style : GUIStyle) : bool
static function Button (position : Rect, content : GUIContent, style : GUIStyle) : bool
Parameters参数
- positionRectangle on the screen to use for the button.
用户按钮在屏幕上的矩形位置。 - 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皮肤。
bool - /true/ when the users clicks the button
当用户点击按钮的时候返回true。
Description描述
Make a single press button. The user clicks them and something happens immediately.
创建一个单次按下按钮。用户点击按钮事件立即触发。
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.Button(new Rect(10, 10, 50, 50), btnTexture))
Debug.Log("Clicked the button with an image");
if (GUI.Button(new Rect(10, 70, 50, 30), "Click"))
Debug.Log("Clicked the button with text");
}
}
//绘制2个按钮一个有图像,另一个是文本
//当按钮被点击的时候打印信息
var btnTexture : Texture;
function OnGUI() {
if (!btnTexture) {
Debug.LogError("Please assign a texture on the inspector");
return;
}
if (GUI.Button(Rect(10,10,50,50),btnTexture))
Debug.Log("Clicked the button with an image");
if (GUI.Button(Rect(10,70,50,30),"Click"))
Debug.Log("Clicked the button with text");
}
最后修改:2011年1月14日 Friday 20:29