| 1 | using System.Collections; |
| 2 | using System.Collections.Generic; |
| 3 | using UnityEngine; |
| 4 | using UnityEngine.UI; |
| 5 | |
| 6 | // Loads Sample Scenes |
| 7 | public class StartMenu : MonoBehaviour |
| 8 | { |
| 9 | public OVROverlay overlay; |
| 10 | public OVROverlay text; |
| 11 | public OVRCameraRig vrRig; |
| 12 | |
| 13 | void Start() |
| 14 | { |
| 15 | DebugUIBuilder.instance.AddLabel("Select Sample Scene"); |
| 16 | DebugUIBuilder.instance.AddButton("Avatar Grab", LoadAvatarGrab); |
| 17 | DebugUIBuilder.instance.AddButton("Custom Controllers", LoadCustomControllers); |
| 18 | DebugUIBuilder.instance.AddButton("Custom Hands", LoadCustomHands); |
| 19 | DebugUIBuilder.instance.AddButton("Debug UI", LoadDebugUI); |
| 20 | DebugUIBuilder.instance.AddButton("Distance Grab", LoadDistanceGrab); |
| 21 | DebugUIBuilder.instance.AddButton("Guardian Boundary System", LoadGuardianBoundarySystem); |
| 22 | DebugUIBuilder.instance.AddButton("Locomotion", LoadLocomotion); |
| 23 | DebugUIBuilder.instance.AddButton("Mixed Reality Capture", LoadMixedRealityCapture); |
| 24 | DebugUIBuilder.instance.AddButton("OVR Overlay", LoadOVROverlay); |
| 25 | DebugUIBuilder.instance.Show(); |
| 26 | } |
| 27 | |
| 28 | // Can't guarantee build order won't change, so use strings for loading |
| 29 | void LoadScene(string sceneName) |
| 30 | { |
| 31 | DebugUIBuilder.instance.Hide(); |
| 32 | StartCoroutine(ShowOverlayAndLoad(sceneName)); |
| 33 | } |
| 34 | |
| 35 | IEnumerator ShowOverlayAndLoad(string sceneName) |
| 36 | { |
| 37 | text.transform.position = vrRig.centerEyeAnchor.position + Vector3.ProjectOnPlane(vrRig.centerEyeAnchor.forward, Vector3.up).normalized * 3f; |
| 38 | overlay.enabled = true; |
| 39 | text.enabled = true; |
| 40 | // Waiting to prevent "pop" to new scene |
| 41 | yield return new WaitForSeconds(1f); |
| 42 | // Load Scene and wait til complete |
| 43 | AsyncOperation asyncLoad = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(sceneName); |
| 44 | while(!asyncLoad.isDone) |
| 45 | { |
| 46 | yield return null; |
| 47 | } |
| 48 | yield return null; |
| 49 | } |
| 50 | |
| 51 | #region Scene Load Callbacks |
| 52 | void LoadAvatarGrab() |
| 53 | { |
| 54 | LoadScene("AvatarGrab"); |
| 55 | } |
| 56 | void LoadCustomControllers() |
| 57 | { |
| 58 | LoadScene("CustomControllers"); |
| 59 | } |
| 60 | void LoadCustomHands() |
| 61 | { |
| 62 | LoadScene("CustomHands"); |
| 63 | } |
| 64 | void LoadDebugUI() |
| 65 | { |
| 66 | LoadScene("DebugUI"); |
| 67 | } |
| 68 | void LoadDistanceGrab() |
| 69 | { |
| 70 | LoadScene("DistanceGrab"); |
| 71 | } |
| 72 | void LoadGuardianBoundarySystem() |
| 73 | { |
| 74 | LoadScene("GuardianBoundarySystem"); |
| 75 | } |
| 76 | void LoadLocomotion() |
| 77 | { |
| 78 | LoadScene("Locomotion"); |
| 79 | } |
| 80 | void LoadMixedRealityCapture() |
| 81 | { |
| 82 | LoadScene("MixedRealityCapture"); |
| 83 | } |
| 84 | void LoadOVROverlay() |
| 85 | { |
| 86 | LoadScene("OVROverlay"); |
| 87 | } |
| 88 | #endregion |
| 89 | } |