Creating the UI Manager

The Controller for all buttons and scene management

Creating the UI Manager:

Once again, we are going to create a new script which will contain the singleton pattern. By now this process should be engrained into our memory. Once you have the basic structure down, we are basically going to add two functions, “Restart” and “Quit”. Since we are using buttons which will affect the scene management, we will need access to that library.

Restarting:

Get the Unity Engine SceneManagment library, then we are going to create an public method called “Restart”. In this method we are going to use the scene management function and call the “LoadScene” script. Depending on how many scenes you have in your build, each scene is assigned an index number. For now, since I only have one active scene, that main scene has an index of zero. Since the function of restart is to start over the current scene, I will place the load scene to index zero, therefore starting over again.

Quiting:

Same as restarting, the Quit method is also going to a public method. Unfortunately since we are still testing the game, the quit function won’t be active. But we can still write the script.

--

--

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.

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
Simon Truong

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.