123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- using System;
- using UnityEngine;
- using UnityEngine.VR;
- public class OVRSceneSampleController : MonoBehaviour
- {
- private void Awake()
- {
- OVRCameraRig[] componentsInChildren = base.gameObject.GetComponentsInChildren<OVRCameraRig>();
- if (componentsInChildren.Length == 0)
- {
- Debug.LogWarning("OVRMainMenu: No OVRCameraRig attached.");
- }
- else if (componentsInChildren.Length > 1)
- {
- Debug.LogWarning("OVRMainMenu: More then 1 OVRCameraRig attached.");
- }
- else
- {
- this.cameraController = componentsInChildren[0];
- }
- OVRPlayerController[] componentsInChildren2 = base.gameObject.GetComponentsInChildren<OVRPlayerController>();
- if (componentsInChildren2.Length == 0)
- {
- Debug.LogWarning("OVRMainMenu: No OVRPlayerController attached.");
- }
- else if (componentsInChildren2.Length > 1)
- {
- Debug.LogWarning("OVRMainMenu: More then 1 OVRPlayerController attached.");
- }
- else
- {
- this.playerController = componentsInChildren2[0];
- }
- }
- private void Start()
- {
- if (!Application.isEditor)
- {
- Cursor.visible = false;
- Cursor.lockState = CursorLockMode.Locked;
- }
- if (this.cameraController != null)
- {
- this.gridCube = base.gameObject.AddComponent<OVRGridCube>();
- this.gridCube.SetOVRCameraController(ref this.cameraController);
- }
- }
- private void Update()
- {
- this.UpdateRecenterPose();
- this.UpdateVisionMode();
- if (this.playerController != null)
- {
- this.UpdateSpeedAndRotationScaleMultiplier();
- }
- if (Input.GetKeyDown(KeyCode.F11))
- {
- Screen.fullScreen = !Screen.fullScreen;
- }
- if (Input.GetKeyDown(KeyCode.M))
- {
- VRSettings.showDeviceView = !VRSettings.showDeviceView;
- }
- if (Input.GetKeyDown(this.quitKey))
- {
- Application.Quit();
- }
- }
- private void UpdateVisionMode()
- {
- if (Input.GetKeyDown(KeyCode.F2))
- {
- this.visionMode ^= this.visionMode;
- OVRManager.tracker.isEnabled = this.visionMode;
- }
- }
- private void UpdateSpeedAndRotationScaleMultiplier()
- {
- float num = 0f;
- this.playerController.GetMoveScaleMultiplier(ref num);
- if (Input.GetKeyDown(KeyCode.Alpha7))
- {
- num -= this.speedRotationIncrement;
- }
- else if (Input.GetKeyDown(KeyCode.Alpha8))
- {
- num += this.speedRotationIncrement;
- }
- this.playerController.SetMoveScaleMultiplier(num);
- float num2 = 0f;
- this.playerController.GetRotationScaleMultiplier(ref num2);
- if (Input.GetKeyDown(KeyCode.Alpha9))
- {
- num2 -= this.speedRotationIncrement;
- }
- else if (Input.GetKeyDown(KeyCode.Alpha0))
- {
- num2 += this.speedRotationIncrement;
- }
- this.playerController.SetRotationScaleMultiplier(num2);
- }
- private void UpdateRecenterPose()
- {
- if (Input.GetKeyDown(KeyCode.R))
- {
- OVRManager.display.RecenterPose();
- }
- }
- public KeyCode quitKey = KeyCode.Escape;
- public Texture fadeInTexture;
- public float speedRotationIncrement = 0.05f;
- private OVRPlayerController playerController;
- private OVRCameraRig cameraController;
- public string layerName = "Default";
- private bool visionMode = true;
- private OVRGridCube gridCube;
- }
|