[Issue] Unity's new scripting API doesn't allow scene loading by Application class

I’ve had to upgrade to Unity 5.4 for work, and so I can’t do the course in 4.7 (and also don’t care to learn a code no one is using here). That being the case, as the course progresses I’m running into more problems with coding the way the course does. One big problem in this section is the fact that the Application class no longer handles level management. Everything goes through the SceneManager class. It works better in a lot of cases, but you can’t call it in a script without first calling it as a namespace type (using UnityEngine.Scenemanagement;).

The upside is that I’m engaging the code a lot more, which helps with understanding it more deeply. It does, however, greatly slow down my pace of learning. Is there somewhere in the documentation or discussion for the course where API changes are explained, or are there any updates to the videos forthcoming?

2 Likes

You can always know about deprecated things by reading the changes:

google smth like this: "whats changed unity 5"
You’ll fine quite a lot of deprecated APIs in this page: https://unity3d.com/unity/whats-new/unity-5.3

Hint for adding the namespace easily:

  1. In Visual Studio after writing “SceneManager” you’ll get a squiggly line.
  2. press “Ctrl + period”
  3. add from the context menu

The actual new code usage? No. Not really. The API tells you what it is but in many cases there is no example yet. The Unity community will reply and help. I agree that these changes come and it slows you down. The one thing I have been able to do is learn where to get the answers. The Community on Unity and in here are the best 2 spots. Answers will help you but might not explain it well the first time. The page that Rumple showed is telling us about the changes but not how to use them. It’s basically release info. There are some examples of the Unity interface but for coding… well not much.

I went here and found many different topics about the new SceneManagement tools. https://unity3d.com/search?gq=SceneManager Try there. I am trying to solve a problem with the PlayerPrefs Manager and stumbling thru things with it at the moment.

If you have the space on your machine Eric, it is a simple matter to have both versions of Unity.

Hi all, I’m using Unity 5.4 when following the course. So how do I use the SceneManager.sceneCountInBuildSettings instead of Application.levelCount? I can’t find any good examples on Unity help or the web. If I replace Application.levelCount with SceneManager.sceneCountInBuildSettings then I get the error "The name ‘SceneManager’ does not exist in the current context. I also tried loading “using UnityEditor”.

Hi @Rob_Willemse,

Try adding using UnityEngine.SceneManagement; at the top of you class.

Hope this helps.

2 Likes

Thanks Rob, that solved my problem. :wink:

1 Like

Great! Glad you have it sorted :slight_smile:

1 Like

Privacy & Terms