Unity 6.3
0 онлайн 0 гостей 3 в системе
Вход

GUILayout.BeginScrollView

Declaration

public static Vector2 BeginScrollView(Vector2 scrollPosition, params GUILayoutOption[] options);
public static Vector2 BeginScrollView(Vector2 scrollPosition, bool alwaysShowHorizontal, bool alwaysShowVertical, params GUILayoutOption[] options);
public static Vector2 BeginScrollView(Vector2 scrollPosition, GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar, params GUILayoutOption[] options);
public static Vector2 BeginScrollView(Vector2 scrollPosition, GUIStyle style);
public static Vector2 BeginScrollView(Vector2 scrollPosition, GUIStyle style, params GUILayoutOption[] options);
public static Vector2 BeginScrollView(Vector2 scrollPosition, bool alwaysShowHorizontal, bool alwaysShowVertical, GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar, params GUILayoutOption[] options);
public static Vector2 BeginScrollView(Vector2 scrollPosition, bool alwaysShowHorizontal, bool alwaysShowVertical, GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar, GUIStyle background, params GUILayoutOption[] options);

Параметры

Параметр Описание
scrollPosition Положение для использования дисплея.
alwaysShowHorizontal Необязательный параметр для постоянного отображения горизонтальной строки прокрутки. Если false или опущено, то она отображается только в том случае, если содержимое внутри ScrollView шире, чем сама строка прокрутки.
alwaysShowVertical Необязательный параметр для постоянного отображения вертикальной строки прокрутки. Если false или опущено, то она будет отображаться только в том случае, если содержимое в ScrollView выше, чем сама строка прокрутки.
horizontalScrollbar Необязательное GUIStyle для использования в горизонтальной панели прокрутки. Если оно опущено, используется стиль horizontalScrollbar из текущего GUISkin.
verticalScrollbar Необязательное GUIStyle для использования вертикальной прокрутки. Если оно опущено, используется стиль verticalScrollbar из текущего GUISkin.

Возвращаемое значение

Vector2 Модифицированный scrollPosition. Введите его обратно в переменную, которую вы передали, как показано в примере.

Описание

Запустите автоматически созданное прокручивание.

Автоматически расположенные прокрутки будут брать любое содержимое, которое вы имеете внутри них, и отображать его нормально. Если оно не вписывается, будут появляться панели прокруток. BeginScrollView должен всегда соответствовать вызову на EndScrollView.


Прокрутка Вид в Game Вид..

using UnityEngine;

public class ExampleScript : MonoBehaviour { // The variable to control where the scrollview 'looks' into its child elements. Vector2 scrollPosition;

// The string to display inside the scrollview. 2 buttons below add & clear this string. string longString = "This is a long-ish string";

void OnGUI() { // Begin a scroll view. All rects are calculated automatically - // it will use up any available screen space and make sure contents flow correctly. // This is kept small with the last two parameters to force scrollbars to appear. scrollPosition = GUILayout.BeginScrollView( scrollPosition, GUILayout.Width(100), GUILayout.Height(100));

// We just add a single label to go inside the scroll view. Note how the // scrollbars will work correctly with wordwrap. GUILayout.Label(longString);

// Add a button to clear the string. This is inside the scroll area, so it // will be scrolled as well. Note how the button becomes narrower to make room // for the vertical scrollbar if (GUILayout.Button("Clear")) longString = "";

// End the scrollview we began above. GUILayout.EndScrollView();

// Now we add a button outside the scrollview - this will be shown below // the scrolling area. if (GUILayout.Button("Add More Text")) longString += "\nHere is another line"; } }