-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoreGUIWidgetsExample.cs
More file actions
129 lines (109 loc) · 4.05 KB
/
CoreGUIWidgetsExample.cs
File metadata and controls
129 lines (109 loc) · 4.05 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
using UnityEngine;
using static CoreGUI;
public class CoreGUIWidgetsExample : MonoBehaviour
{
public Side labelSide = Side.Left;
string normalText;
string areaText;
string passwordText;
float floatValue;
int intValue;
bool boolValue;
Rect rectValue;
Bounds boundsValue;
Color colorValue = new Color(0, 0.5f, 0.8f, 0.5f);
Quaternion quaternionValue;
Vector2 vector2Value;
Vector3 vector3Value;
Vector4 vector4Value;
Vector2 scroll;
bool foldout;
public GUISkin skin;
public float scale = 1;
float refScale;
private void Start()
{
scale = Utility.ScaleFromDPI(96);
floatValue = Utility.pixelsPerPoint;
}
private void OnGUI()
{
BeginGUI(this, Utility.screenRect, skin, scale);
using (Scoped.LabelOption(labelSide <= Side.Right ? 120 : -1, labelSide))
using (Scoped.ScrollView(ref scroll))
using (Scoped.Vertical(null, Layout.MinWidth(500)))
using (Scoped.Indent())
{
Label(C("GUI Core Widgets", "Lorem Ipsum"));
Label(C("Settings"));
using (Scoped.Indent())
{
labelSide = EnumPopup(C("Label Side"), labelSide);
scale = Utility.GetDeferredValue(scale, x => FloatSlider(C("Scale"), x, 0.5f, 3f));
}
Label(C("Strings"));
using (Scoped.Indent())
{
normalText = TextField(C("Normal Text"), normalText);
areaText = TextArea(C("Text Area"), areaText, 1, 5);
passwordText = PasswordField(C("Password"), passwordText, '●');
}
Label(C("Numbers"));
using (Scoped.Indent())
{
floatValue = FloatField(C("Float Field"), floatValue);
intValue = IntField(C("Int Field"), intValue);
floatValue = FloatSlider(C("Float Range"), floatValue, 0, 10);
intValue = IntSlider(C("Int Range"), intValue, 0, 10);
}
Label(C("Vectors"));
using (Scoped.Indent())
{
vector2Value = VectorField(C("Vector 2"), vector2Value);
vector3Value = VectorField(C("Vector 3"), vector3Value);
vector4Value = VectorField(C("Vector 4"), vector4Value);
quaternionValue = QuaternionField(C("Euler"), quaternionValue);
}
Label(C("Structs"));
using (Scoped.Indent())
{
colorValue = ColorField(C("Color"), colorValue);
rectValue = RectField(C("Rect"), rectValue);
boundsValue = BoundsField(C("Bounds"), boundsValue);
}
Scoped.FadeGroup(Foldout(C("Foldout"), ref foldout), () =>
{
using (Scoped.Horizontal(C("Buttons")))
{
using (Scoped.Vertical())
{
if (Button(C("Lorem ipsum dolor sit amett")))
MessagePopup.Show("This is the Title", "This is a message box");
if (Button(C("Click me")))
MessagePopup.Show(0, "Something is right", "Sorry sir it's not broken....",
MessagePopup.ButtonScheme.ContinueRetryAbort);
}
using (Scoped.Vertical())
{
if (Button(C("Beep boop")))
{
#if UNITY_EDITOR
UnityEditor.Selection.activeObject = GUI.skin;
#endif
}
Button(C("Another button here"));
}
}
using (Scoped.Indent())
{
Label(C("Lorem Ipsum dolor sit amet"));
Label(C("Lorem Ipsum dolor sit amet"));
Label(C("Lorem Ipsum dolor sit amet"));
}
});
scroll = DragScrollView(scroll);
}
DrawTooltips();
EndGUI();
}
}