Creating a retro game over screen in Unity is pretty straightforward. All that’s really needed is a few text elements.
The UI Manager script has serialized fields, that I’ve dragged the text elements into. For my game over screen, I wanted the main text to be static, with a flashing “instruction” underneath it. All other parts of the UI are hidden, except the score.
When the player dies the UI Manager is told that the game is over, and starts a coroutine that takes care of the rest 😀
Handling the player pressing the R key is handled by a different script since that technically has nothing to do with the UI.
Unity makes it easy for us to create a User-Interface (UI) for our game.
Right-clicking in the hierarchy and going into the UI section of the menu that pops up, gives you a list of various elements to use.
As you can see, most of them are pretty self-explanatory 😀
Swapping out if-else if-else with a Switch statement.
If you have an if-else statement with several different conditions to check for, it can get quite unruly, fast.
By using switch statements instead, you end up with something where it is easier to see what is happening.