Managers, Main Menu and Loading screen

This is the last article about The Great Fleece that I have been working on (for far to long). In this article, I’ll be covering The Singleton Pattern used for making manager scripts, what I did for the main menu and how I made the loading screen.

The Singleton Pattern, most commonly used for manager scripts in programming. Manager scripts, are as they sound, they manage different processes of the project. Game Manager, UI Manager, etc. The game manager would manage the states of the game. The UI Manager, manages different parts of the User Interface for the game. So on and so forth. The reason it is mostly used on manager scripts is because you would only ever need a SINGLE instance of that script. Only a single game manager, a single UI manager. With this single instance though, it allows for ease of access across all other scripts.

The way this allows for ease of access across all other scripts is a static reference. It’s basically allowing all other scripts to connect to this script without it having to be “copied”. The static keyword here sets the GameManger or Manager script into memory allowing it to be used across the entire project.

Then in awake, you set the instance to be that script grabbing the proper reference for it to be X manager.

Next on the list is the Main Menu. Quick and simple set up, background Image. (Title Text) Image. A start and quit button. The start button and quit buttons are linked to a script using the On Click method. It’s set up through the inspector in this case, but it is possible to set it up through script. The start button loads the next scene — in this case the loading screen. The quit button, would quit the application.

The loading screen is a progress bar, the yellow image. It is set to fill horizontally, and the fill amount is a float between 0 and 1. Having this in mind, using the SceneManagement Unity Library. We can use a Asynchronous operation, meaning it happens at different times. So while we’re in the loading screen, in the background it is loading the main scene. Using the progress of that operation, we tie it to the fill amount of the progress bar. Once it’s done, we’re done.

With that we’re at the end of the Stealth and Cinematography course. The Great Fleece has been a fun project.
On to the next!

--

--

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