EditorGUILayout.BeginScrollView()

单纯的做了个小实验,想把它记录下来。没什么技术含量。

来看含义解析

public static Vector2 BeginScrollView(Vector2 scrollPosition, params GUILayoutOption[] options);

scrollPosition The position to use display.

Returns

Vector2 The modified scrollPosition. Feed this back into the variable you pass in, as shown in the example.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class BeginScrollViewExample : EditorWindow
{
    Vector2 scrollPos;
    string t = "This is a string inside a Scroll view!";

    [MenuItem("Examples/Modify internal Quaternion")]
    static void Init()
    {
        BeginScrollViewExample window = (BeginScrollViewExample)EditorWindow.GetWindow(typeof(BeginScrollViewExample), true, "My Empty Window");
        window.Show();
    }

    void OnGUI()
    {
        EditorGUILayout.BeginHorizontal();
        scrollPos =
            EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(100), GUILayout.Height(100));
        GUILayout.Label(t);
        EditorGUILayout.EndScrollView();

        if (GUILayout.Button("Add More Text", GUILayout.Width(100), GUILayout.Height(100)))
            t += " \nAnd this is more text!";
        EditorGUILayout.EndHorizontal();

        if (GUILayout.Button("Clear"))
            t = "";
    }
}

运行结果刚开始是这样的: 

EditorGUILayout.BeginScrollView()_第1张图片

点击Add More Text是这样的:

EditorGUILayout.BeginScrollView()_第2张图片

再点击Clear是这样的:

EditorGUILayout.BeginScrollView()_第3张图片

 

 

你可能感兴趣的:(Unity游戏开发)