Unity3D 基础篇--button入门
来源:互联网 发布:天刀女神威捏脸数据 编辑:程序博客网 时间:2024/05/16 19:32
Button是Unity3D中GUI系统的常用控件,其函数原型如下:
staticfunction Button(position: Rect, text: string):bool;staticfunction Button(position: Rect, image: Texture): bool;staticfunction Button(position: Rect, content: GUIContent): bool;staticfunction Button(position: Rect, text: string, style: GUIStyle): bool;staticfunction Button(position: Rect, image: Texture, style: GUIStyle): bool;staticfunction Button(position: Rect, content: GUIContent, style: GUIStyle): bool;
参数说明:
position : Rect ——屏幕上的矩形位置(x坐标,y坐标,宽度,高度)。
text : String ——显示的文本内容。
image : Texture ——显示的纹理(图片)。
content : GUIContent ——在标签上显示的文本、图片和信息提示。
style : GUIStyle ——使用的样式,如果不使用,那么标签的样式使用的就是当前的GUISkin皮肤
按钮共有三个基本状态组成:未点击状态、击中状态、点击后状态。一般情况下,游戏界面的按钮只监听“未点击状态”与“点击后状态”两种。
按钮展现方式分为两种:“普通按钮”和“图片按钮”。普通按钮为系统默认显示的按钮,而图片按钮可以设定按钮的背景图案。
下面以实际简单的代码为例:
publicclassButtons : MonoBehaviour { publicTexture buttonTexture; privatestringinfo = ""; voidStart () { } //Update is called once per frame voidUpdate () { } voidOnGUI() { // 文本显示 GUI.Label (newRect (50, 200, 200, 50), info); // 第一个文字按钮 GUI.color = Color.yellow; //按钮文字颜色 GUI.backgroundColor = Color.red; //按钮背景颜色 if(GUI.Button(newRect(50,250,200,30),"Button1")) { info = "按下了Button1"; } // 第二个图片按钮 GUI.color = Color.white; //按钮文字颜色 GUI.backgroundColor = Color.green; //按钮背景颜色 if(GUI.Button(newRect(50,300,128,64), buttonTexture)) { info = "按下了Button2"; } }}
0 0
- Unity3D 基础篇--button入门
- unity3d 基础入门
- Unity3d-C#入门基础
- Unity3D 4.0 界面 基础 入门
- Unity3D入门——GUI之Button和RepeatButton控件
- WinForm基础篇----button
- 学习Unity3D第一天之基础入门。
- Unity3d 开发-基础篇
- Unity3D基础篇-Transform
- Unity3D 基础篇-Camera
- Android unity3d button加载
- Android零基础入门第19节:Button使用详解
- Button基础
- Button基础
- unity3d插件Daikon Forge GUI 中文教程-3-基础控件Button和Sprite的使用
- unity3D入门
- unity3d入门
- Unity3D入门
- android java资源包下载网站
- iOS基础UI瀑布流界面简单搭建
- Android 中常见的小知识总结
- Activiti 工作流的三个小问题
- 【ZYNQ-7000开发之十五】Vivado HLS和OpenCV_下
- Unity3D 基础篇--button入门
- WPF-GRID分割多窗口 用Grid和GridSplitter布局和分割WPF窗口
- POJ 2186 Popular Cows 强连通分量
- curl参数列表
- 四种软件开发模型对比:
- Maven的Snapshot版本与Release版本
- mongo3.0基础篇
- 修改HttpServletRequest的中的参数值
- LRU Cache