Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
GUI.Label 标签
# [GUI](GUI.html).Label 标签 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 ### Parameters**参数** * *position* Rectangle on the screen to use for the label. 标签使用的在屏幕上矩形的位置 * *text* Text to display on the label. 在标签上显示的文本 * *image* Texture to display on the label. 在标签上显示的纹理 * *content* Text, image and tooltip for this label. 在标签上显示的文本,图片和信息提示 * *style* The style to use. If left out, the label style from the current GUISkin is used. 使用样式,如果不使用那么,标签样式应用当前的 GUISKin 皮肤。 *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](GUI.Box.html) control. 标签没有用户交互,不捕捉鼠标点击,并总是被渲染为普通样式,如果你想创建响应用户输入的可视化控件,使用 [Box](GUI.Box.html) 控件。 Example: Draw the classic Hello World! string: 举例:绘制一个经典的 Hello World!字符串:  Text label on the Game View. 在游戏视图中的文本标签。 * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example : MonoBehaviour { void OnGUI() { GUI.Label(new Rect(10, 10, 100, 20), "Hello World!"); } } ``` ``` function OnGUI () { GUI.Label(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. 纹理标签 * [C#](#) * [JavaScript](#) ``` 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); } } ``` ``` var textureToDisplay : Texture2D; function OnGUI () { GUI.Label(Rect(10, 40, textureToDisplay.width, textureToDisplay.height),textureToDisplay); } ```
da
2022年5月23日 13:48
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码