Loading Scenes in Unity!!

In every game, there is a starting point — where player or user engage himself to understand the information about the game, its features/levels, controls etc.

Each of these respective section of game are made of Scenes and they are loaded based on when the user or player interact within the game.

In our Galaxy Shooter 2D- lets create a new scene — that is loaded first time when game starts and provides information about the game, who created it and how one can start the new game i.e, load another scene from the first scene.

File->New Scene

Click on File-> New Scene , it will create a new scene and save it say “Main_Menu”

Inside Canvas- Added Image with size of 512 X 512

Inside Canvas — added image MainMenu and updated it with name Title-Screen_Image and set the size of image as provided in width, height.

Canvas -Click Right -> Select UI and Add Elements as desired

Here in our case we will add the button and the text and update the text as below

Added Button with Text

And we can add the text and provide information who created the game set few properties like alignment needs wrap or overflow text horizontal or vertical.

Added Text and set properties

Once scene is created- one can add the scenes in Build when click on Add open Scenes or drag the scene from the Project tab from scene folder . The scene which are added under build settings assigned with an index number which one can refer in code to load the scene.

Click on -Add open scenes and it will add it

Now when we run the Game , it will load the Main_Menu Scene and when click on New Game, there will be on click event handler is called at run-time on button and it calls the MainMenu.LoadGame method.

On Click ()-> called MainMenu.LoadGame() method

This MainMenu script is added to the canvas and when it calls the LoadGame() method it loads the Scene having index -1, which open the Game Scene.

MainMenu Script -> which loads the Game Scene

Below shows when the MainMenu is selected , it open the Game Scene..

Game Scene loaded when click on New Game Scene

@GameDevHQ-Day …

--

--

--

I am a passionate technologist with a strong aptitude for new skills that includes Exploring and Learning Unity 3D Scripting APIs… !!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Java 13 — New Language Features

Antipattern: Filling in the Corners

Collect Windows logs with Winlogbeat

Closing reflection of my second week

Why use Ruby and ActiveRecord and?

How normally is done

L’Hopital’s rule and Sandwich theorem in Python

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Anurag Chawla

Anurag Chawla

I am a passionate technologist with a strong aptitude for new skills that includes Exploring and Learning Unity 3D Scripting APIs… !!

More from Medium

Adding a collectible ammo charge powerup

2D Mobile: Setting Up The Player

Modeling An Elevator Console With Unity ProBuilder

Creating objects in Unity