Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Application.loadedLevel - Obsolete

Discussion in '5.3 Beta' started by DxStd_IgnatPribylov, Oct 11, 2015.

  1. DxStd_IgnatPribylov

    DxStd_IgnatPribylov

    Joined:
    Sep 24, 2015
    Posts:
    30
    Where?
    It was that: restart the scen:
    Code (CSharp):
    1. private IEnumerator ReloadLevel(Entry entry)
    2.         {
    3.             yield return new WaitForSeconds(entry.delay);
    4.             SceneManager.LoadScene(Application.loadedLevel, false);
    5.         }
     
    Last edited: Oct 11, 2015
  2. superpig

    superpig

    Quis aedificabit ipsos aedificatores? Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,283
    The problem is that Application.loadedLevel doesn't really make sense in a situation where you can have multiple levels loaded at the same time.

    If you know that you only have one level loaded, you can use GetSceneAt to access it like this:

    Code (csharp):
    1.  
    2. private Enumerator ReloadLevel(Entry entry)
    3. {
    4.     yield return new WaitForSeconds(entry.delay);
    5.     SceneManager.LoadScene (SceneManager.GetSceneAt(0).buildIndex, false);
    6. }
    7.  
     
    LaurieAnnis likes this.
unityunity