【Unity 3D】学习笔记七:ScrollView控件(滚动视图)

来源:互联网 发布:淘宝如何设置运费险 编辑:程序博客网 时间:2024/05/19 20:49

Unity 学习笔记七

 

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

 

在应用中,有的时候文本大于边框,为了不丢失文本内容和更好的排版。那么就得使用ScrollView控件来滚动。

 

例子

 

//滚动条位置var scrollPosition : Vector2;function Start(){//初始化滚动条位置scrollPosition[0] = 50;scrollPosition[1] = 50;}function OnGUI () {    //设置开始滚动视图scrollPosition = GUI.BeginScrollView (Rect (10,10,200,200),scrollPosition, Rect (0, 0, Screen.width, 300),true,true);GUI.Label(Rect(20, 30, Screen.width, 30), "测试滚动视图,测试滚动视图,测试滚动视图,测试滚动视图。测试滚动视图测试滚动视图测试滚动视图测试滚动视图");GUI.Label(Rect(20, 50, Screen.width, 30), "测试滚动视图,测试滚动视图,测试滚动视图,测试滚动视图。测试滚动视图测试滚动视图测试滚动视图测试滚动视图");GUI.Label(Rect(20, 70, Screen.width, 30), "测试滚动视图,测试滚动视图,测试滚动视图,测试滚动视图。测试滚动视图测试滚动视图测试滚动视图测试滚动视图");GUI.Label(Rect(20, 90, Screen.width, 30), "测试滚动视图,测试滚动视图,测试滚动视图,测试滚动视图。测试滚动视图测试滚动视图测试滚动视图测试滚动视图");GUI.Label(Rect(20, 110, Screen.width, 30), "测试滚动视图,测试滚动视图,测试滚动视图,测试滚动视图。测试滚动视图测试滚动视图测试滚动视图测试滚动视图");    //设置结束滚动视图GUI.EndScrollView ();}

QQ截图20140605103344

 

QQ截图20140605103357

 

ScrollView控件使用文档:

QQ截图20140605102840

0 0
原创粉丝点击