Search Unity

Loading new scene in background (VR)

Discussion in 'Scripting' started by adri1992, Oct 12, 2016.

  1. adri1992


    Dec 14, 2015
    Hi everyone!

    My project is with VR, using Samsung Gear VR.

    I've two scenes:

    1.- the initial scene
    2.- second scene, with big quantity of data (it takes too much time to load the scene).

    So, from the first scene, I want to load the second scene in background and once the new scene has been loaded, then change the scene. I would like that while the new scene is loading in background, the user can move their head to see any part of the VR environment.

    I'm using SceneManager.LoadSceneAsync but it not works:

    Code (CSharp):
    1. ....
    2. StartCoroutiune(loadScene());
    3. ----
    5. IEnumerator loadScene(){
    6.         AsyncOperation async = SceneManager.LoadAsyncScene("Scene", LoadSceneMode.Single);
    7.         async.allowSceneActivation = false;
    8.         while(async.progress < 0.9f){
    9.               progressText.text = async.progress+"";
    10.         }
    11.        while(!async.isDone){
    12.               yield return null;
    13.         }
    14.         async.allowSceneActivation = true;
    15. }
    With that code, the scene never changes.

    I've tried this the typical "SceneManager.LoadScene("name")" and in this case the scene changes correctly after 30 seconds.

    ¿Any idea?

    Thanks so much!
    Last edited: Oct 13, 2016
    jacknoid likes this.
  2. b4th


    Jul 4, 2016