-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathEditorGUIUtilityEx.cs
51 lines (41 loc) · 1.04 KB
/
EditorGUIUtilityEx.cs
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
using System.Collections.Generic;
using UnityEditor;
namespace cmdwtf.UnityTools.Editor
{
/// <summary>
/// Utilities specific to the <see cref="EditorGUIUtility"/> class.
/// </summary>
public static class EditorGUIUtilityEx
{
private static readonly Stack<float> _labelWidths = new();
private static readonly Stack<float> _fieldWidths = new();
public static void PushLabelWidth(float width)
{
_labelWidths.Push(EditorGUIUtility.labelWidth);
EditorGUIUtility.labelWidth = width;
}
public static bool PopLabelWidth()
{
if (!_labelWidths.TryPop(out float width))
{
return false;
}
EditorGUIUtility.labelWidth = width;
return true;
}
public static void PushFieldWidth(float width)
{
_fieldWidths.Push(EditorGUIUtility.fieldWidth);
EditorGUIUtility.fieldWidth = width;
}
public static bool PopFieldWidth()
{
if (!_fieldWidths.TryPop(out float width))
{
return false;
}
EditorGUIUtility.fieldWidth = width;
return true;
}
}
}