Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

load level async and wait for a keypress?

Discussion in 'Scripting' started by TheRaider, Sep 27, 2011.

  1. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,245
    Is there a way to this.

    I can see the loadlevel async is working, but I would like it to load and then press to start.
     
  2. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
  3. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,245
    but loadlevelasync automatically loads the next level when loaded?
     
  4. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
  5. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,245
    I did, and I followed the example and it immediatly loads.

    Maybe it is just me but I can't see where in the documentation it allows me to wait for a keypress.
     
  6. ReneBaumgartner

    ReneBaumgartner

    Joined:
    May 3, 2014
    Posts:
    13
    Found this old thread, maybe this helps someone

    Code (CSharp):
    1.    
    2. IEnumerator LoadLevelAsyncCoroutine()
    3. {
    4.     AsyncOperation async = Application.LoadLevelAsync("myLevelToLoad");
    5.        
    6.     // this line prevents the scene from instant activation
    7.     async.allowSceneActivation = false;
    8.  
    9.     while(waitForSomething == true)
    10.         yield return null;
    11.  
    12.     // activate Scene now
    13.     async.allowSceneActivation = true;
    14.  
    15.     yield return async;
    16. }
    17.  
     
    sd_trent, id0 and ElDivinCodino like this.
  7. ElDivinCodino

    ElDivinCodino

    Joined:
    Apr 17, 2016
    Posts:
    5
    It actually helped me a lot, almost 3 years later! :D Thank you!
     
    yagopessoa likes this.