Legacy Documentation: Version 2018.1 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

FadeGroupScope

class in UnityEditor

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Begins a group that can be be hidden/shown and the transition will be animated.

#pragma strict
public class MyWindow extends EditorWindow {
	var m_ShowExtraFields: AnimBool;
	var m_String: String;
	var m_Color: Color = Color.white;
	var m_Number: int = 0;
	@MenuItem("Window/My Window")
	static function Init() {
		var window: MyWindow = MyWindowEditorWindow.GetWindow(MyWindow);
		window.Show();
	}
	function OnEnable() {
		m_ShowExtraFields = new AnimBool(true);
		m_ShowExtraFields.valueChanged.AddListener(new UnityAction(.Repaint));
	}
	function OnGUI() {
		m_ShowExtraFields.target = EditorGUILayout.ToggleLeft("Show extra fields", m_ShowExtraFields.target);
		var group: var = 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--;
			}
		}
	}
}
using UnityEngine;
using UnityEditor;
using UnityEditor.AnimatedValues;
using UnityEngine.Events;

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.AddListener(new UnityAction(base.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--; } } } }

Properties

visibleWhether the group is visible.

Constructors

EditorGUILayout.FadeGroupScopeCreate a new FadeGroupScope and begin the corresponding group.

Did you find this page useful? Please give it a rating: