Version: 2017.1

FadeGroupScope

class in UnityEditor

切换到手册

描述

开始一个可隐藏/显示的组,并且过渡将生成动画。

using UnityEngine;
using UnityEditor;
using UnityEditor.AnimatedValues;

public class MyWindow : EditorWindow { AnimBool m_ShowExtraFields; string m_String; Color m_Color = Color.white; int m_Number = 0;

[MenuItem("Window/My Window")] static void Init() { MyWindow window = (MyWindow)EditorWindow.GetWindow(typeof(MyWindow)); window.Show(); }

void OnEnable() { m_ShowExtraFields = new AnimBool(true); m_ShowExtraFields.valueChanged = Repaint; }

void OnGUI() { m_ShowExtraFields.target = EditorGUILayout.ToggleLeft("Show extra fields", m_ShowExtraFields.target);

//Extra block that can be toggled on and off. using (var group = new EditorGUILayout.FadeGroupScope(m_ShowExtraFields.faded)) { if (group.visible) { EditorGUI.indentLevel++; EditorGUILayout.PrefixLabel("Color"); m_Color = EditorGUILayout.ColorField(m_Color); EditorGUILayout.PrefixLabel("Text"); m_String = EditorGUILayout.TextField(m_String); EditorGUILayout.PrefixLabel("Number"); m_Number = EditorGUILayout.IntSlider(m_Number, 0, 10); EditorGUI.indentLevel--; } } } }

变量

visible组是否可见。

构造函数

EditorGUILayout.FadeGroupScope创建一个新的 FadeGroupScope 并开始相应的组。
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961