Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
941 B

  1. namespace Oculus.Platform
  2. {
  3. using UnityEditor;
  4. using UnityEngine;
  5. class GUIHelper {
  6. public delegate void Worker();
  7. static void InOut(Worker begin, Worker body, Worker end) {
  8. try {
  9. begin();
  10. body();
  11. } finally {
  12. end();
  13. }
  14. }
  15. public static void HInset(int pixels, Worker worker) {
  16. InOut(
  17. () => {
  18. GUILayout.BeginHorizontal();
  19. GUILayout.Space(pixels);
  20. GUILayout.BeginVertical();
  21. },
  22. worker,
  23. () => {
  24. GUILayout.EndVertical();
  25. GUILayout.EndHorizontal();
  26. }
  27. );
  28. }
  29. public delegate T ControlWorker<T>();
  30. public static T MakeControlWithLabel<T>(GUIContent label, ControlWorker<T> worker) {
  31. EditorGUILayout.BeginHorizontal();
  32. EditorGUILayout.LabelField(label);
  33. var result = worker();
  34. EditorGUILayout.EndHorizontal();
  35. return result;
  36. }
  37. }
  38. }