Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Game Development How to Make a Video Game Score, Enemies, and Game State Add a Start and End

Travis Barry
Travis Barry
9,020 Points

Application.LoadLevel obsolete :(

I am having a problem at the end step of this video and I found on the unity API that I should use "SceneManager.LoadScene" instead of "Application.LoadLevel" but it is still quite unclear

My question is how would you apply this into the code? Do I have to use

SceneManager.LoadScene (SceneManager.loadedLevel);

like using Application.LoadLevel? Or do I have to make it it's own void function? At the level of understanding I'm at the API is hard to read :(

Thank you for all and any help :)

2 Answers

Nick Pettit
Nick Pettit
Treehouse Teacher

Hi Travis,

Application.LoadLevel was only recently deprecated; I just tried it in the project with Unity 5.3.2 and it still works. However, if for some reason it's preventing you from running the game, you can try this. Change out the Application.LoadLevel line for this:

// ...then reload the currently loaded level.

Then at the top of the script, you need to add the namespace for scene management, like this.

using UnityEngine.SceneManagement;
Travis Barry
Travis Barry
9,020 Points

Oh! Thank you so much! I knew I was on the right track but I just knew I was missing something from the code :p

By the way I am loving your course on unity :)