CurvedUIInputModuleEditor.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEditor;
  5. using UnityEditor.UI;
  6. namespace CurvedUI {
  7. [CustomEditor(typeof(CurvedUIInputModule))]
  8. public class CurvedUIInputModuleEditor : Editor {
  9. bool opened = false;
  10. #if CURVEDUI_GOOGLEVR
  11. bool isGVR = true;
  12. #else
  13. bool isGVR = false;
  14. #endif
  15. void OnEnable()
  16. {
  17. CurvedUIInputModule myTarget = (CurvedUIInputModule)target;
  18. #if CURVEDUI_OCULUSVR
  19. //automatically find Oculus Rig, if possible
  20. if (myTarget.OculusCameraRig == null)
  21. myTarget.OculusCameraRig = Object.FindObjectOfType<OVRCameraRig>();
  22. #elif CURVEDUI_STEAMVR_LEGACY
  23. //automatically find SteamVR Rig, if possible
  24. if (myTarget.SteamVRControllerManager == null)
  25. myTarget.SteamVRControllerManager = Object.FindObjectOfType<SteamVR_ControllerManager>();
  26. #elif CURVEDUI_STEAMVR_2
  27. //automatically find SteamVR Rig, if possible
  28. if (myTarget.SteamVRPlayArea == null)
  29. myTarget.SteamVRPlayArea = FindObjectOfType<Valve.VR.SteamVR_PlayArea>();
  30. #endif
  31. }
  32. public override void OnInspectorGUI()
  33. {
  34. EditorGUILayout.HelpBox("Use CurvedUISettings component on your Canvas to configure CurvedUI", MessageType.Info);
  35. if (isGVR)//on GVR we draw all the stuff.
  36. {
  37. DrawDefaultInspector();
  38. }
  39. else
  40. {
  41. if (opened)
  42. {
  43. if (GUILayout.Button("Hide Fields"))
  44. opened = !opened;
  45. DrawDefaultInspector();
  46. }
  47. else
  48. {
  49. if (GUILayout.Button("Show Fields"))
  50. opened = !opened;
  51. }
  52. }
  53. GUILayout.Space(20);
  54. }
  55. }
  56. }