How to Manage Scenes in Unity

Posted March 21, 2020 by Joudet Ahsan in Unity

Unity games are not just composed of one scene. Games rarely have one level. Many games consist of infinite levels. Ever heard of the infinite runner? Such games have random behavior added to them. We have already discussed the effects of randomness in games. This tech-recipe will show how you can Manage Scenes in Unity

What is a scene? In the game world, anything you see forms a part of the scene. The environment, trees, grass, materials, houses, enemies, etc. And apart from the game objects, even the menus you see to navigate inside the game are part of the scene. You can think of a scene as a separate and unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces.

When you create a new project in unity an empty scene is formed. By default, the scene has a directional light and a camera. And an environment for you to fill. When all the scenes are ready, you can either duplicate the scene and make some changes to achieve different levels. Main menu of the game is also a scene.

In the next tech-recipe, we will show you how to create a menu. So, once you have your menu, all you need to do is to attach all the scenes together. Unity scene manager will help you arrange everything in your game. All you have to do is to follow a few simple steps to manage the scenes in your game.

Manage Scenes in Unity

Step-By-Step Procedure:

1. Make sure you have all the scenes present in the scenes folder in project. This step is important for management purpose.

2. Now Click on the File in the top. 

3. Click on build settings.

4. Simply drop your scenes, in the order of levels. E.g Menu then level 1, level 2 and onwards.

5. Now when you build your project the scenes will be in order.

6. For further scene management, simply add a script to your menu scene.

7. Add scene management library.

8. In the menu when the play button is to be clicked, the script needs to use the load scene method. The build index is the order in which you dropped your scenes in build settings in step 5

9. SceneManager.LoadScene(“myscene”, LoadSceneMode.Single). With this method you can access the load the scene using the name of the scene or the build number that you assigned.

Check out other tech-recipes

How to Set Camera to Follow the Player in Unity | 3D Game Development

How to Add Rigidbody to a Gameobject in Unity | 3D Game Development

Detect Collision in Unity | 3D Game Development

How Can I run Unity 3d in Windows 7 64-bit?

How to Perform Simple Animation in Unity | 3D Game Development

 

 

About Joudet Ahsan

SEO Content Creator, a Computer Scientist in making and someone who sucks at writing bios.
View more articles by Joudet Ahsan

The Conversation

Follow the reactions below and share your own thoughts.

Leave a Reply