Search Unity

Oculus Rift S Run in Background not working?

Discussion in 'AR/VR (XR) Discussion' started by saifshk17, Feb 24, 2020.

  1. saifshk17

    saifshk17

    Joined:
    Dec 4, 2016
    Posts:
    488
    Hello,

    If i remove and keep the oculus rift s headset aside while the Unity player (64-bit) is running and wear the headset again after 20-25 minutes, i only see a black screen with gazepointer and the whole Unity freezes. It takes 5 minutes or sometimes 10 minutes for the Oculus Rift S to go into resume mode. How do I fix this? I even wrote a script for running the app in background, it runs well but when I wear the HMD again, then it goes into freeze mode.

    Code (CSharp):
    1.      public bool debugLog = false;
    2.      public bool runInBackgroundValue = true;
    3.      void Awake () {
    4.      }
    5.      // Use this for initialization
    6.      void Start () {
    7.          Application.runInBackground = true;
    8.      }
    9.    
    10.      // Update is called once per frame
    11.      void Update () {
    12.          if (debugLog) {
    13.              runInBackgroundValue = Application.runInBackground;
    14.          }
    15.          if (!Application.runInBackground) {
    16.              Application.runInBackground = true;
    17.              if (debugLog) {
    18.                  Debug.Log("Re-Setting Application.runInBackground to TRUE at: " + Time.time);
    19.              }
    20.          }
    21.      }