Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
GUI.FocusControl 焦点控件
# [GUI](GUI.html "Go to GUI scripting documentation").*FocusControl* 焦点控件 static function *FocusControl* (*name* : [String](../String/String.html)) : void *Description* 描述 Move keyboard focus to a named control. 移动键盘焦点到被命名的控件。 参考:[SetNextControlName](GUI.SetNextControlName.html), [GetNameOfFocusedControl](GUI.GetNameOfFocusedControl.html). * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example : MonoBehaviour { public string username = "username"; public string pwd = "a pwd"; void OnGUI() { GUI.SetNextControlName("MyTextField"); username = GUI.TextField(new Rect(10, 10, 100, 20), username); pwd = GUI.TextField(new Rect(10, 40, 100, 20), pwd); if (GUI.Button(new Rect(10, 70, 80, 20), "Move Focus")) GUI.FocusControl("MyTextField"); } } ``` ``` //当按下按钮,选择"username"文本字段,也就是获得焦点 var username : String = "username"; var pwd : String = "a pwd"; function OnGUI () { //设置文本字段一个内部名字 GUI.SetNextControlName ("MyTextField"); //创建用户名和密码文本字段 username = GUI.TextField (Rect (10,10,100,20), username); pwd = GUI.TextField (Rect (10,40,100,20), pwd); // 如果按下按钮键盘焦点将移动到用户名文本字段 if (GUI.Button (Rect (10,70,80,20), "Move Focus")) GUI.FocusControl ("MyTextField"); } ```
da
2022年5月23日 13:45
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码