Creating a Manager Classes in Unity
How to control the flow of your game
In game development in most cases we will need a piece of code in charge of managing general things separated from the mechanics or the main gameplay functionalities, things like UI management, Audio management, state of the game and more.
There are a lot of ways to solve this but the most common is to create a script called GameManager and start defining different functions and properties to control every general aspect of the game. Also you can have different scripts, one for UI, one for Audio, etc…
Also there are some predefined solutions for specific cases called Game Programming Patterns. In easy words the Game Programming Patterns are ways to write a code to make it cleaner, easier to understand, faster and designed to solve common problems about game development. If you want to know more about this, here I leave you a link to a book with more information: