Search Unity

LoadSceneAsync in Coroutine or Function?

Discussion in 'Scripting' started by Abhinav91, Feb 9, 2016.

  1. Abhinav91

    Abhinav91

    Joined:
    Oct 21, 2013
    Posts:
    67
    Hey everyone, hope ya'll are doing well.
    So recently I've been doing some research on SceneManager.LoadSceneAsync and noticed that in a lot of the examples that I was seeing, SceneManager.LoadSceneAsync was being called in a Coroutine, rather than a regular function. So I was just wondering, is it preferable to call SceneManager.LoadLevelAsync in a Coroutine or a void function? If so, why?
     
  2. Abhinav91

    Abhinav91

    Joined:
    Oct 21, 2013
    Posts:
    67
    Anyone?
     
  3. pixpusher2

    pixpusher2

    Joined:
    Oct 30, 2013
    Posts:
    121
    Coroutine is preferable because you don't know when the loading will be completed. Coroutine allows the rest of the app to continue running while waiting for the loading to finish.
     
    Abhinav91 likes this.
  4. Abhinav91

    Abhinav91

    Joined:
    Oct 21, 2013
    Posts:
    67