GUISkin.scrollView 滚动视图

var scrollView : GUIStyle

Description描述

Style used by default for the background of ScrollView controls (see GUI.BeginScrollView).

用于ScrollView控件背景的默认样式。(参见GUI.BeginScrollView

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public Vector2 scrollPosition = Vector2.zero;
	public GUIStyle style;
	void OnGUI() {
		GUI.skin.scrollView = style;
		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();
	}
}
// Modifies only the background of the ScrollView controls
// of the current GUISkin.
//修改当前GUISkin的ScrollView控件背景的样式

var scrollPosition : Vector2 = Vector2.zero;
var style : GUIStyle;

function OnGUI () {

	GUI.skin.scrollView = style;
	// rect and put it in a small rect on the screen.
	//在屏幕上定位一块小区域
	scrollPosition = GUI.BeginScrollView (Rect (10,300,100,100),
	scrollPosition, Rect (0, 0, 220, 200));

	// Make four buttons - one in each corner. The coordinate system is defined
	// by the last parameter to BeginScrollView.
	//创建4个按钮,分布在每一个角
	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");

	// End the scroll view that we began above.
	//结束滚动视图
	GUI.EndScrollView ();
}
Page last updated: 2011-1-25