GUI
- backgroundColor
- BeginGroup
- BeginScrollView
- Box
- BringWindowToBack
- BringWindowToFront
- Button
- changed
- color
- contentColor
- depth
- DragWindow
- DrawTexture
- enabled
- EndGroup
- EndScrollView
- FocusControl
- FocusWindow
- GetNameOfFocusedControl
- GUI
- HorizontalScrollbar
- HorizontalSlider
- Label
- matrix
- PasswordField
- RepeatButton
- ScrollTo
- SelectionGrid
- SetNextControlName
- skin
- TextArea
- TextField
- Toggle
- Toolbar
- tooltip
- UnfocusWindow
- VerticalScrollbar
- VerticalSlider
- Window
GUI.ScrollTo 滚动至
static function ScrollTo (position : Rect) : void
Description描述
Scrolls all enclosing scrollviews so they try to make position visible.
滚动scrollviews到position指定的位置,通俗来说就是把内容滚动到指定的坐标。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public Vector2 scrollPos = Vector2.zero;
void OnGUI() {
scrollPos = GUI.BeginScrollView(new Rect(10, 10, 100, 50), scrollPos, new Rect(0, 0, 220, 10));
if (GUI.Button(new Rect(0, 0, 100, 20), "Go Right"))
GUI.ScrollTo(new Rect(120, 0, 100, 20));
if (GUI.Button(new Rect(120, 0, 100, 20), "Go Left"))
GUI.ScrollTo(new Rect(0, 0, 100, 20));
GUI.EndScrollView ();
}
}
var scrollPos : Vector2 = Vector2.zero;
function OnGUI () {
scrollPos = GUI.BeginScrollView(Rect (10, 10, 100, 50), scrollPos, Rect(0, 0, 220, 10));
//绘制一个滚动视窗
if(GUI.Button(Rect (0,0,100,20), "Go Right"))
//左边创建一个按钮,点击将滚动到右边
GUI.ScrollTo(Rect (120,0,100,20));
if(GUI.Button(Rect (120,0,100,20) , "Go Left"))
//右边创建一个按钮,点击将滚动到左边
GUI.ScrollTo(Rect (0,0,100,20));
// 结束滚动视图
GUI.EndScrollView ();
}
最后修改:2011年1月14日 Friday 21:36