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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

What would I replace 'if (Application.loadedLevel == 1)' with using scene manager?

Discussion in 'Editor & General Support' started by Blinking_Nora, Jan 5, 2016.

  1. Blinking_Nora

    Blinking_Nora

    Joined:
    Dec 17, 2015
    Posts:
    11
    Hi folks!

    I've just finished optimising my scene code in my Unity game to go from using load level to scene manager. However I have the last bit to do now and that's with this code:

    Code (csharp):
    1. if (Application.loadedLevel == 1)
    I've tried a number of different ways of using SceneManager, but I just can't figure out what to do. All I want it to do is check to see what level it is, and if it's level 1 (as listed in the Unity build index), then run the code below. But I keep getting bugged about how the code's now obsolete but I don't know how to fix it. :/

    Thanks in advance guys!
     
  2. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
  3. Blinking_Nora

    Blinking_Nora

    Joined:
    Dec 17, 2015
    Posts:
    11
    Thanks chum, you're a hero! The code works great now, and I don't constantly get the warning message everytime I add more code to my scripts and save them haha.

    Thanks again for the help. :)