2
0

SteamVR_ForceSteamVRMode.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using UnityEngine;
  2. using System.Collections;
  3. namespace Valve.VR.Extras
  4. {
  5. /// <summary>
  6. /// This is an example class of how to force steamvr initialization. You still need to have vr mode enabled
  7. /// but you can have the top sdk set to None, then this script will force it to OpenVR after a second
  8. /// </summary>
  9. public class SteamVR_ForceSteamVRMode : MonoBehaviour
  10. {
  11. public GameObject vrCameraPrefab;
  12. public GameObject[] disableObjectsOnLoad;
  13. private IEnumerator Start()
  14. {
  15. yield return new WaitForSeconds(1f); // just here to show that you can wait a while.
  16. SteamVR.Initialize(true);
  17. while (SteamVR.initializedState != SteamVR.InitializedStates.InitializeSuccess)
  18. yield return null;
  19. for (int disableIndex = 0; disableIndex < disableObjectsOnLoad.Length; disableIndex++)
  20. {
  21. GameObject toDisable = disableObjectsOnLoad[disableIndex];
  22. if (toDisable != null)
  23. toDisable.SetActive(false);
  24. }
  25. GameObject.Instantiate(vrCameraPrefab);
  26. }
  27. }
  28. }