GUI.EndScrollView 结束滚动视图

static function EndScrollView () : void

Description描述

Ends a scrollview started with a call to BeginScrollView.

结束被开始的滚动视图,注意BeginScrollView和EndScrollView它们是成对出现的。

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));

//每个角创建一个按钮,注意他们的坐标是相对于滚动视图的左上角0,0
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 ();
}
Page last updated: 2011-1-14