Advertisement
Guest User

Untitled

a guest
Nov 11th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.XR;
  5. using UnityEngine.SceneManagement;
  6.  
  7. public class VrModeChanger : MonoBehaviour
  8. {
  9. public string menuSceneName;
  10. void Awake()
  11. {
  12. StartCoroutine(LoadDevice("Cardboard"));
  13. }
  14.  
  15. IEnumerator LoadDevice(string newDevice)
  16. {
  17. XRSettings.LoadDeviceByName(newDevice);
  18. yield return null;
  19. XRSettings.enabled = true;
  20. }
  21.  
  22. public void DeactivateVr()
  23. {
  24. XRSettings.enabled = false;
  25. }
  26.  
  27. private void Update()
  28. {
  29. if(Input.GetKeyDown(KeyCode.Escape))
  30. {
  31. SceneManager.LoadScene(menuSceneName);
  32. DeactivateVr();
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement