Just some info for getting level count in 2017.3 if you are using the new version of unity for this course

The Application.levelCount doesn’t work in unity 2017. If you want to get the level count you will have to add ScreneManger to your Project

using UnityEngine.ScreneManager

Then replace Application.levelCount with SceneManager.sceneCountInBuildSettings . If you try using SceneManager.SceneCount you will get a total of 1 Scene. SceneCount only counts the current number of loaded scenes where sceneCountInBuildSettings counts all scenes listed in the BuildSettings.

3 Likes

Nice post Tom, although the using directive should be;

using UnityEngine.SceneManagement;

Hope this helps :slight_smile:

I switched the application.LevelCount with SceneManager.sceneCountInBuildSettings. Everything else is the same from the code Ben wrote and the behavior is not optimal. If I unlock level 2 but ask if level 3 is unlocked I will get a debug.Log that tells me that level 2 and level 3 are both unlocked.

Thanks!

No problem :slight_smile:

Privacy & Terms