Creating the UI Manager

The Controller for all buttons and scene management

Simon Truong
3 min readAug 28, 2021

The third class that will have the singleton pattern will be the UI Manager. The UI Manager will be responsible for all the button actions and the ability to restart or quit during the endgame scene.

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.


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.


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.

Back in Unity, we are going to add the functionality to the buttons we have created before.

In the button component at the “On Click” section, click the Plus icon to add an functionality. Drag the UIManager game object into the slot and at the drop down menu, you should be able to see all of the Public methods we have created. Match the proper function to the method (restart > restart).

Now when the UI appears, the buttons should be able to function, with the exception of Quit.



Simon Truong

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