static function Label (position : Rect, text : string) : void
static function Label (position : Rect, image : Texture) : void
static function Label (position : Rect, content : GUIContent) : void
static function Label (position : Rect, text : string, style : GUIStyle) : void
static function Label (position : Rect, image : Texture, style : GUIStyle) : void
static function Label (position : Rect, content : GUIContent, style : GUIStyle) : void
Description描述
Make a text or texture label on screen.
在屏幕上创建一个文本或者纹理标签。
Labels have no user interaction, do not catch mouse clicks and are always rendered in normal style. If you want to make a control that responds visually to user input, use a Box control.
标签没有用户交互,不捕捉鼠标点击,并总是被渲染为普通样式,如果你想创建响应用户输入的可视化控件,使用Box控件。
Example: Draw the classic Hello World! string:
举例:绘制一个经典的Hello World!字符串:
Text label on the Game View.
在游戏视图中的文本标签。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
void OnGUI() {
GUI.Label(new Rect(10, 10, 100, 20), "Hello World!");
}
}
Example: Draw a texture on-screen. Labels are also used to display textures, instead of a string, simply pass in a texture:
举例:在屏幕上绘制一个纹理。标签也可以用来显示纹理,而不仅仅用来显示字符串,简单传递一个纹理:
Texture Label. 纹理标签
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public Texture2D textureToDisplay;
void OnGUI() {
GUI.Label(new Rect(10, 40, textureToDisplay.width, textureToDisplay.height), textureToDisplay);
}
}