unity自带GUI之控件的焦点获取
来源:互联网 发布:知乎体验分析报告 编辑:程序博客网 时间:2024/05/19 02:20
using UnityEngine;
using System.Collections;
public class SetConFocus : MonoBehaviour {
public string username = "username";
public string pwd = "a pwd";
public string pwds = "a pwds";
int count = 1;
private bool isopen = false;
void OnGUI()
{ /***********设置下一个控件的名字****************/
GUI.SetNextControlName("MyTextField");
GUI.Button(new Rect(10, 10, 100, 20), username);
GUI.SetNextControlName("TEXT2");
GUI.Button(new Rect(10, 40, 100, 20), pwd);
GUI.SetNextControlName("TEXT3");
GUI.Button(new Rect(10, 70, 100, 20), pwds);
/*************按一下button的时候,名字为MyTextField的控件获得焦点*******************/
if (GUI.Button(new Rect(10, 100, 80, 20), "Move Focus"))
{
Debug.Log(count);
if (count % 3 == 0)
{
GUI.FocusControl("MyTextField");
isopen = true;
}
else if (count % 3 == 1)
{
GUI.FocusControl("TEXT2");
}
else
{
GUI.FocusControl("TEXT3");
}
count++;
}
}
void Update(){
/*********焦点在上面的时候,就响应一些事件************/
if (isopen)
{
if (Input.GetKeyDown(KeyCode.Return))
{
isopen = false;
Debug.Log("the t button is pressed");
Debug.Log("the MyTextField is pressed");
}
}
}
using System.Collections;
public class SetConFocus : MonoBehaviour {
public string username = "username";
public string pwd = "a pwd";
public string pwds = "a pwds";
int count = 1;
private bool isopen = false;
void OnGUI()
{ /***********设置下一个控件的名字****************/
GUI.SetNextControlName("MyTextField");
GUI.Button(new Rect(10, 10, 100, 20), username);
GUI.SetNextControlName("TEXT2");
GUI.Button(new Rect(10, 40, 100, 20), pwd);
GUI.SetNextControlName("TEXT3");
GUI.Button(new Rect(10, 70, 100, 20), pwds);
/*************按一下button的时候,名字为MyTextField的控件获得焦点*******************/
if (GUI.Button(new Rect(10, 100, 80, 20), "Move Focus"))
{
Debug.Log(count);
if (count % 3 == 0)
{
GUI.FocusControl("MyTextField");
isopen = true;
}
else if (count % 3 == 1)
{
GUI.FocusControl("TEXT2");
}
else
{
GUI.FocusControl("TEXT3");
}
count++;
}
}
void Update(){
/*********焦点在上面的时候,就响应一些事件************/
if (isopen)
{
if (Input.GetKeyDown(KeyCode.Return))
{
isopen = false;
Debug.Log("the t button is pressed");
Debug.Log("the MyTextField is pressed");
}
}
}
}
效果图:
- unity自带GUI之控件的焦点获取
- Unity之自带shader
- u3d 自带GUI学习之 GUILayout
- unity3d之自带GUI (一)
- 获取 拥有焦点的控件
- java GUI中JTextField的requestFocus()方法获取不到焦点
- 导入unity自带的包出问题
- Unity自带的寻路
- Unity自带的网络编程方式
- 模拟unity自带地形的grass
- 关于unity自带的雾
- Asp .NET控件获取焦点的常见问题
- Delphi获取焦点所在的控件名
- WPF 自带控件 总结之二
- Android自带的软键盘上面移动焦点
- Android自带的软键盘上面移动焦点
- Unity自带函数
- C#编写Unity基础GUI之按钮控件
- struts2的编程式非空验证
- BMP文件结构
- img 滤波
- 死锁ora-60诊断
- JAVA帮助文档全系列 JDK1.5 JDK1.6 JDK1.7 官方中英完整版下载
- unity自带GUI之控件的焦点获取
- dojo 中文博客地址
- fmt:formatDate的输出格式
- OpenMP: 几个容易混淆的函数
- 关于nginx开启特定路径的ssl证书验证
- 倍受关注的Visual Studio插件
- Python的编码机制,unicode, utf-8, utf-16, GBK, GB2312,ISO-8859-1 等编码之间的转换
- java 笔记 2013—04—16
- 算法策略的总结