【Unity 3D】学习笔记四:Toolbar控件(工具栏)

来源:互联网 发布:mac 模拟人生4 语言包 编辑:程序博客网 时间:2024/05/08 01:04

Unity 学习笔记四

 

学习资料:《Unity 3D游戏开发》 宣雨松

 

在程序中通常都会设有工具栏如下图:

QQ截图20140604091932

 

Toolbar控件便是用于创建工具栏,并且以Tab页面的形式来展现,选择其中的任何一项,都会返回所选项的ID,然后根据所返回的ID,进行下一步的操作。

 

例子

 

//工具栏选择按钮的IDvar select : int;//工具栏显示按钮的字符串var barResource : String[];function Start(){//初始化select = 0;barResource = ["File","Edit","Assets","GameObject","component","terrain","window","Help"];}function OnGUI () {//重新计算本次工具栏选择的IDselect = GUI.Toolbar(Rect (10, 10, barResource.length * 80, 30), select, barResource);//根据工具栏选择的ID 显示不同的信息switch(select){case 0:GUI.Label(Rect(10, 50, 200, 30), "你选择的是:" + barResource[select]);break;case 1:GUI.Label(Rect(90, 50, 200, 30), "你选择的是:" + barResource[select]);break;case 2:GUI.Label(Rect(170, 50, 200, 30), "你选择的是:" + barResource[select]);    break;case 3:GUI.Label(Rect(250, 50, 200, 30), "你选择的是:" + barResource[select]);break;case 4:GUI.Label(Rect(330, 50, 200, 30), "你选择的是:" + barResource[select]);break;case 5:GUI.Label(Rect(410, 50, 200, 30), "你选择的是:" + barResource[select]);break;case 6:GUI.Label(Rect(490, 50, 200, 30), "你选择的是:" + barResource[select]);break;case 7:GUI.Label(Rect(570, 50, 200, 30), "你选择的是:" + barResource[select]);break;}}

图片上传后就成这样模糊了,点开看是清晰的。


QQ截图20140604104535

 

QQ截图20140604104613

 

QQ截图20140604104631

 

重点:

 

QQ截图20140604104818

0 0