Search Unity

Placeholder image Unity 2
Placeholder image Unity 2
Share

Many exciting new features are coming as part of the Unity 5.x release cycle, but we are also making improvements to our existing features and workflows. One of those areas is our level management and scene editing.

For various reasons, it is sometimes necessary to divide a game level into multiple scenes in Unity. This could be because the level is big and/or you want to support streaming of parts of the level. You might also decide to divide the level to make it easier for multiple people to work on the same level without creating too many conflicts in the scene files.

Whatever your reasons for dividing a level into multiple scenes were, you probably had to write some editor tools for supporting multiple scenes. If you used it for level streaming, you probably wanted to have multiple scenes in the editor in order to align geometry properly or maybe you wanted to combine multiple scenes into one scene before building the player.

At runtime in the player it is already possible to load multiple scenes at once using APIs like Application.LoadLevelAdditive. Unfortunately, there has never been the equivalent UnloadLevel. So while loading additional data is straightforward, unloading data required for you to do bookkeeping of the game objects created when loading additional data or to structure your scene in a way that made it easy to destroy the scene again.

For those of you who are familiar with these issues, we would like to introduce you to the SceneManager. The SceneManager is a new API that makes it easy for you to manage your scene at runtime. It handles all the necessary bookkeeping of game objects, so you do not have to think about which game objects to destroy when unloading a level.

Loading a scene additively is simple a matter of calling SceneManager.LoadSceneAdditive(“MyScene”), unloading the scene again is simply SceneManager.UnloadScene(“MyScene”).

There are a few more APIs for handling which scene newly created game object are added to and moving game objects between scenes hierarchically (not spatially) as well as asynchronous versions of the load scene APIs, so you can keep you player busy while loading other parts of your game level.

On top of the SceneManager you can implement the level loading or streaming that suits your game, whether that be based on tunnels and portals or player proximity is completely up to you.

In the Editor, we have used the SceneManager to implement what we call Multi Scene Editing. This feature allows you to have multiple scenes loaded at the same time in the Editor and will look somewhat like this:

Now it will be easy to align you level objects across scenes and move objects between scenes. We are working on how to support the baking of navmesh, lightmap and occlusion culling with multiple scenes loaded. The goal is to have it all working together smoothly.

A bonus that comes with this workflow improvement is that the edited state of each scene is now tracked through the undo system, which will reduce those strange cases where the scene was marked as edited when rearranging tabs or inspecting materials even though the scene was never touched.

NOTE: This feature is not shipping in Unity 5.0 but we are working on it for a later release

August 4, 2014 in Technology | 3 min. read