private void Button_Click(int index) { Menu.Hide(); SelectRoom?.Invoke(index); }
public void Update() { if (vrPlaying) { if (Api.IsCloseButtonPressed) { StartCoroutine(StopXR()); Exit?.Invoke(); } if (Api.IsGearButtonPressed) { Api.ScanDeviceParams(); } Api.UpdateScreenParams(); var doRaycast = (Bear.activeInHierarchy && !avatarAwake) || Menu.gameObject.activeInHierarchy; if (doRaycast) { // See if we are looking at the bear var progressDelta = 0f; RaycastHit hit; if (Physics.Raycast(Cam.transform.position, Cam.transform.forward, out hit)) { progressDelta = (1 / ProgressSpeed) * Time.deltaTime; } if (progressDelta > 0) { if (progress < 1) { progress = Mathf.Clamp01(progress + progressDelta); if (GazeProgress) { GazeProgress.fillAmount = progress; } if (progress == 1) { GazeProgress.fillAmount = 0; if (hit.collider.gameObject == Bear) { Bootstrap.Facade.SendNotification(StoryMediator.Notifications.AvatarClicked); avatarAwake = true; } else { var menuItem = Array.IndexOf(MenuColliders, hit.collider.gameObject); if (menuItem > 0) { SelectRoom?.Invoke(menuItem); } } } } } else { progress = 0; } } if (Spinner.activeInHierarchy) { Spinner.transform.Rotate(Vector3.forward, SpinnerRotateSpeed * Time.deltaTime); } #if UNITY_EDITOR var mouseDelta = lastMousePos - Input.mousePosition; lastMousePos = Input.mousePosition; var rotate = new Vector3(mouseDelta.y, -mouseDelta.x, 0) * Time.deltaTime * MouseRotateSpeed; CamRoot.transform.Rotate(rotate); if (Input.GetKeyDown(KeyCode.Escape)) { StopXR(); Exit?.Invoke(); } #endif } }