BlueGit

blue-star ggj-2020

Files

ggj-2020 / Assets / Oculus / Platform / Editor / GUIHelper.cs

GUIHelper.cs

Project Import
timfa Tim Falken · pushed by timfa · 6 years ago
b77834a1 History
GUIHelper.cs 941 B Download Raw
1namespace Oculus.Platform
2{
3 using UnityEditor;
4 using UnityEngine;
5
6 class GUIHelper {
7 public delegate void Worker();
8
9 static void InOut(Worker begin, Worker body, Worker end) {
10 try {
11 begin();
12 body();
13 } finally {
14 end();
15 }
16 }
17
18 public static void HInset(int pixels, Worker worker) {
19 InOut(
20 () => {
21 GUILayout.BeginHorizontal();
22 GUILayout.Space(pixels);
23 GUILayout.BeginVertical();
24 },
25 worker,
26 () => {
27 GUILayout.EndVertical();
28 GUILayout.EndHorizontal();
29 }
30 );
31 }
32
33 public delegate T ControlWorker<T>();
34 public static T MakeControlWithLabel<T>(GUIContent label, ControlWorker<T> worker) {
35 EditorGUILayout.BeginHorizontal();
36 EditorGUILayout.LabelField(label);
37
38 var result = worker();
39
40 EditorGUILayout.EndHorizontal();
41 return result;
42 }
43 }
44
45}