unity传统GUI学习一.
using System.Collections; using System.Collections.Generic; using UnityEngine; public class gui : MonoBehaviour { string editName; string editPassword; float toolBarValue0; float toolBarValue1; public Texture tex; void Start() { editName = "请输入用户名"; editPassword = "请输入密码"; toolBarValue0 = 0; toolBarValue1 = 0; } void OnGUI () { GUI.Label (new Rect (10, 10, 100, 30), "阿峰学习"); //将字符串显示在屏幕上 GUI.DrawTexture (new Rect (10, 50, 100, 80), tex); //绘制贴图 //检测按钮 if (GUI.Button (new Rect (10, 200, 100, 30), "普通按钮")) { Debug.Log ("按下了按钮。"); } //检测连续按钮 if (GUI.RepeatButton (new Rect (10, 250, 100, 30), "连续按钮")) { Debug.Log ("正在按按钮!"); } //设置文本输入框 editName = GUI.TextField (new Rect (150, 40, 200, 30), editName, 15); editPassword = GUI.PasswordField (new Rect (150, 80, 200, 30), editPassword, "*" [0], 15); <br />//垂直和水平滑动条 toolBarValue0 = GUI.VerticalSlider (new Rect (200, 200, 30, 100), toolBarValue0, 100, 0); toolBarValue1 = GUI.HorizontalSlider (new Rect (200, 180, 100, 30), toolBarValue1, 0, 100); } }<br />
相关推荐
mapaler 2020-06-21
MIKUScallion 2020-06-11
wallowyou 2020-03-05
Samlss 2020-02-22
linmufeng 2020-02-18
luvhl 2020-01-10
LodbkMi 2019-04-24
Dickzeng 2019-07-01
Irelia 2019-07-01
laxexue 2019-06-30
飞翔的鱼 2019-06-30
我的iOS王者之路 2019-06-28
yixiaof 2019-06-28
zsh 2018-07-02
yaosir 2019-06-28
xiaocaibai 2016-03-31
bertZuo 2019-06-27