-
Notifications
You must be signed in to change notification settings - Fork 341
Expand file tree
/
Copy pathExample_75_FadeGroup.cs
More file actions
57 lines (51 loc) · 1.96 KB
/
Example_75_FadeGroup.cs
File metadata and controls
57 lines (51 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using Sirenix.Utilities.Editor;
using UnityEngine;
using UnityEditor;
using UnityEditor.AnimatedValues;
namespace UnityToolchinsTrick
{
/// <summary>
///
/// https://blog.csdn.net/qq_42139931/article/details/120686951
/// https://blog.csdn.net/tom_221x/article/details/78475300
/// https://docs.unity3d.com/cn/2017.4/ScriptReference/EditorGUILayout.BeginFadeGroup.html
/// </summary>
public class Example_75_FadeGroupWindow : EditorWindow
{
private AnimBool _showExtraFields;
private string _string;
private Color _color = Color.white;
private int _number = 0;
private bool _foldout;
[MenuItem("Tools/Example_75_FadeGroup", priority = 75)]
static void Init()
{
Example_75_FadeGroupWindow window =
(Example_75_FadeGroupWindow) EditorWindow.GetWindow(typeof(Example_75_FadeGroupWindow));
window.titleContent = new GUIContent("Example_75_FadeGroup");
}
void OnEnable()
{
_showExtraFields = new AnimBool(true);
_showExtraFields.valueChanged.AddListener(Repaint);
}
void OnGUI()
{
_showExtraFields.target =
EditorGUILayout.Foldout(_showExtraFields.target, _showExtraFields.target ? "折叠" : "展开", true);
//Extra block that can be toggled on and off.
if (EditorGUILayout.BeginFadeGroup(_showExtraFields.faded))
{
EditorGUI.indentLevel++;
EditorGUILayout.PrefixLabel("Color");
_color = EditorGUILayout.ColorField(_color);
EditorGUILayout.PrefixLabel("Text");
_string = EditorGUILayout.TextField(_string);
EditorGUILayout.PrefixLabel("Number");
_number = EditorGUILayout.IntSlider(_number, 0, 10);
EditorGUI.indentLevel--;
}
EditorGUILayout.EndFadeGroup();
}
}
}