Version: 2022.1

VerticalScope

class in UnityEditor

切换到手册

描述

用于管理 BeginVertical/EndVertical 的可处置的 Helper 类。

此方法是对 GUILayout.VerticalScope 的扩展。可用于创建复合控件


垂直复合组。

using UnityEngine;
using UnityEditor;

// Create a Vertical Compound Button class VerticalScopeExample : EditorWindow { [MenuItem("Examples/Vertical scope usage")] static void Init() { var window = GetWindow<VerticalScopeExample>(); window.Show(); }

void OnGUI() { using (var v = new EditorGUILayout.VerticalScope("Button")) { if (GUI.Button(v.rect, GUIContent.none)) Debug.Log("Go here"); GUILayout.Label("I'm inside the button"); GUILayout.Label("So am I"); } } }

变量

rect垂直组的矩形。

构造函数

EditorGUILayout.VerticalScope创建一个新的 VerticalScope 并开始相应的垂直组。