Search Unity

VR environment is black while LoadSceneAsync

Discussion in 'AR/VR (XR) Discussion' started by adri1992, Oct 13, 2016.

  1. adri1992

    adri1992

    Joined:
    Dec 14, 2015
    Posts:
    34
    I'm trying to load a large scene through *SceneManager.LoadSceneAsync* in a VR project.

    It seems that works fine, because the new scene is loaded after 30 seconds approximately, but I see two problems:

    1. Once the progress of the AsyncOperation object has finished (it takes 1 or 2 seconds to finish), the app seems "frozen" and the user only can see the area that is renderized (if the user move their head in any direction of 360º and try to see a new area, it will be black). I want that the user can see the full environment while the scene is being loading.
    2. The progress duration of the AsyncOperation takes over 2 seconds as I told. After that time, the new scene appears after 30 seconds, so I can't make a real progress bar... Any idea?

    I'm using this code:

    Code (CSharp):
    1.   ...
    2.   StartCoroutine(loadingScene());
    3.   ...
    4.  
    5.   IEnumerator loadingScene(){
    6.  
    7.        yield return null;
    8.  
    9.        AsyncOperation ao = SceneManager.LoadSceneAsync("Scene");
    10.        ao.allowSceneActivation = false;
    11.  
    12.        while (! ao.isDone)
    13.        {
    14.          float progress = Mathf.Clamp01(ao.progress / 0.9f);
    15.          progressText.text = progress+"";
    16.          if (ao.progress == 0.9f)
    17.          {
    18.            ao.allowSceneActivation = true;
    19.          }
    20.  
    21.          yield return null;
    22.        }
    23.   }
    Check this image to see that the user see if move their head (first problem mentioned). Only is visible the rectangular area that has been rendered:




    The photo has been taken with a smartphone through the Samsung Gear VR lens.

    Thanks so much