Part 6: Changing Scene in Unity

We have done creating image.  Now, we will add function "Click to continue" into our game.

When click the left mouse button, game will change from Scene SplashScene to MainMenu.

In the Project area -> Create -> C# Script, name it is SplashSceneManager, double click in Script which is just created to open visual studio (or mono).


changing scene in unity


Add this code in it:


changing scene in unity 


Now, we have a control, but to work, we need to add it into a GameObject in Scene.

Create an Empty GameObject, name it as SplashSceneManager. Then, drag and drop our c# script file into it.


changing scene in unity


Then, choose File -> Build Settings, drag and drop 2 Scene into "Scenes In Build" like the below image.

This action just likes registration for Unity to understand that we use Scenes selected.

 (The selected Scene will have a check mark in the box on the leftside respectively).

Be sure that Scence 0 will be "the one above all" because Unity will load that Scene first.


changing scene in unity


If you don't do the above step, when game run, Unity will show error like the below picture.


changing scene in unity


After finish, choose the Game window, press Play and click mouse button, our Scence SplashScreen will jump to Scene MainMenu.

Congratulation! Now you know how to create change room Scene. Just follow the step and your will success. Hope you like tutorials of Gamemakerlab, thank you for your visit and see ya in other tutorial.


Create Simple Game Menu Using This Tutorial. The menu will have three buttons PLAY, CREDIT, EXIT. In here, we are making it simple, when we click on the PLAY button, the game will go to the Play Room. If we click on CREDIT button, it will go to the CREDIT Room and if we click on the EXIT button, the game will be stopped and we will exit the application.