Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
GUI.BeginScrollView 开始滚动视图
# [GUI](GUI.html).BeginScrollView 开始滚动视图 static function BeginScrollView (position : Rect, scrollPosition : Vector2, viewRect : Rect) : Vector2 static function BeginScrollView (position : Rect, scrollPosition : Vector2, viewRect : Rect, alwaysShowHorizontal : bool, alwaysShowVertical : bool) : Vector2 static function BeginScrollView (position : Rect, scrollPosition : Vector2, viewRect : Rect, horizontalScrollbar : GUIStyle, verticalScrollbar : GUIStyle) : Vector2 static function BeginScrollView (position : Rect, scrollPosition : Vector2, viewRect : Rect, alwaysShowHorizontal : bool, alwaysShowVertical : bool, horizontalScrollbar : GUIStyle, verticalScrollbar : GUIStyle) : Vector2 ### Parameters**参数** * *position* Rectangle on the screen to use for the ScrollView. 用于滚动视图在屏幕上矩形的位置 * *scrollPosition* The position to use display. 用来显示滚动位置 * *viewRect* The rectangle used inside the scrollview. 滚动视图内使用的矩形 * *alwayShowHorizontal* Optional parameter to always show the horizontal scrollbar. If false or left out, it is only shown when clientRect is wider than position. 可选参数,总是显示水平滚动条,如果 false 或者不设置,它仅在内矩形比外矩形大的时候显示。 * *alwayShowVertical* Optional parameter to always show the vertical scrollbar. If false or left out, it is only shown when clientRect is taller than position. 可选参数,总是显示垂直滚动条,如果 false 或者不设置,它仅在内矩形比外矩形大的时候显示。 * *horizontalScrollbar* Optional GUIStyle to use for the horizontal scrollbar. If left out, the horizontalScrollbar style from the current GUISkin is used. 用于水平滚动条的可选 GUIStyle,如果不设置,水平滚动条样式应用当前的 GUISkin 皮肤。 * *verticalScrollbar* Optional GUIStyle to use for the vertical scrollbar. If left out, the verticalScrollbar style from the current GUISkin is used. 用于垂直滚动条的可选 GUIStyle,如果不设置,垂直滚动条样式应用当前的 GUISkin 皮肤。 *Returns* [Vector2](../Vector2/Vector2.html) - The modified scrollPosition. Feed this back into the variable you pass in, as shown in the example. 返回 Vector2 类型,被修改的滚动位置 *scrollPosition* 。返回值应回传给你的变量,看下面的例子。 *Description* 描述 Begin a scrolling view inside your GUI. 在你的 GUI 里,开始一个滚动视图, 注意 BeginScrollView 和 EndScrollView 它们是成对出现的。 ScrollViews let you make a smaller area on-screen look 'into' a much larger area, using scrollbars placed on the sides of the ScrollView. 滚动视图让你在屏幕上一个小的区域,使用滚动是视图的滚动条查看一个大的区域。 * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example : MonoBehaviour { public Vector2 scrollPosition = Vector2.zero; void OnGUI() { scrollPosition = GUI.BeginScrollView(new Rect(10, 300, 100, 100), scrollPosition, new Rect(0, 0, 220, 200)); GUI.Button(new Rect(0, 0, 100, 20), "Top-left"); GUI.Button(new Rect(120, 0, 100, 20), "Top-right"); GUI.Button(new Rect(0, 180, 100, 20), "Bottom-left"); GUI.Button(new Rect(120, 180, 100, 20), "Bottom-right"); GUI.EndScrollView(); } } ``` ``` //定义默认的滚动条位置为0,0 var scrollPosition : Vector2 = Vector2.zero; function OnGUI () { //我们创建一个100,100的滚动视图,滚动内容为220,200,就是我们要查看的内容比滚动视图大 scrollPosition = GUI.BeginScrollView (Rect (10,300,100,100),scrollPosition, Rect (0, 0, 220, 200)); // 我们创建一个100,100的滚动视图,滚动内容为220,200,就是我们要查看的内容比滚动视图大 // 返回值赋回给我们定义的变量 GUI.Button (Rect (0,0,100,20), "Top-left"); GUI.Button (Rect (120,0,100,20), "Top-right"); GUI.Button (Rect (0,180,100,20), "Bottom-left"); GUI.Button (Rect (120,180,100,20), "Bottom-right"); // 结束滚动视图 GUI.EndScrollView (); } ```
da
2022年5月23日 13:40
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码