13

Loading Level Scenes

Loading and saving Scenes in Unity is done with the built in SceneManager class. SceneManager offers a range of utilities for Scenes – everything from straight loading to combining and manipulating multiple Scenes at the same time.

The RunMan game example from Chapter 2 used SceneManager to load the game from the main menu using SceneManager.LoadScene(). It is a function that will load a new Scene and unload the current one without you having to do anything further. Later in this book, the Blaster and Racing Game examples both use an alternative method that loads two Scenes, combines them together into one and then manually unloads the current Scene. This is useful in cases where the game logic remains the same throughout, ...

Get C# Game Programming Cookbook for Unity 3D, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.