Version: 2022.1
言語: 日本語
public static Vector2 BeginScrollView (Rect position, Vector2 scrollPosition, Rect viewRect);
public static Vector2 BeginScrollView (Rect position, Vector2 scrollPosition, Rect viewRect, bool alwaysShowHorizontal, bool alwaysShowVertical);
public static Vector2 BeginScrollView (Rect position, Vector2 scrollPosition, Rect viewRect, GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar);
public static Vector2 BeginScrollView (Rect position, Vector2 scrollPosition, Rect viewRect, bool alwaysShowHorizontal, bool alwaysShowVertical, GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar);

パラメーター

position スクロールビューで使用するスクリーン上の Rect
scrollPosition ビューが X と Y 方向にスクロールされているピクセル単位の距離
viewRect スクロールビュー内部で使用する Rect
horizontalScrollbar 水平スクロールバーで使用するGUIStyleのオプションパラメーター。false や省略した場合は、現在使用されているGUISkinから horizontalScrollbar のスタイルを使用します。
verticalScrollbar 垂直スクロールバーで使用するGUIStyleのオプションパラメーター。false や省略した場合は、現在使用されているGUISkinから verticalScrollbar のスタイルを使用します。
alwaysShowHorizontal 常に水平移動のスクロールバーを表示するかのオプションパラメーター。false や省略した場合は viewRectposition よりも広くなっている場合のみ表示されます。
alwaysShowVertical 常に垂直移動のスクロールバーを表示するかのオプションパラメーター。false や省略した場合は viewRectposition よりも広くなっている場合のみ表示されます。

戻り値

Vector2 The 変更された scrollPosition 。例にあるように戻り値として得た値は変数に渡します。

説明

スクロールビューを開始します

スクロールビューは両側に配置されたスクロールバーを使用してスクリーン上で小さな範囲だとしても広い範囲を見ることが可能になります。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { // The position on of the scrolling viewport public Vector2 scrollPosition = Vector2.zero;

void OnGUI() { // An absolute-positioned example: We make a scrollview that has a really large client // rect and put it in a small rect on the screen. scrollPosition = GUI.BeginScrollView(new Rect(10, 300, 100, 100), scrollPosition, new Rect(0, 0, 220, 200));

// Make four buttons - one in each corner. The coordinate system is defined // by the last parameter to BeginScrollView. 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");

// End the scroll view that we began above. GUI.EndScrollView(); } }