Day 22 | A Retro Game Over Screen

Ted Lim
2 min readApr 20, 2021

--

In this article, we’ll cover how to make a retro Game Over screen with Unity UI and a little bit of code.

A Retro Effect with Coroutines

Retro Game Over screens are well-known for their flicker effect.

We can mimic this effect easily with the ever-so-useful Coroutine function. First, we’ll create some UI Text objects that we want to flicker and put them in a Canvas object called UI_Manager.

We’ll attach a script to the UI_Manager called UIManagerScript, and we’ll add the following code:

Remember that Unity uses IEnumerators to stall functions mid execution. Therefore, we created the IEnumerator Flicker() function for our Coroutine and used the following logic to make our text flicker: Turn on our text, wait 1 second, Turn off our text, wait 1 second, and repeat.

With this, we’ve made standalone UI Text that flickers. If you call the DisplayGameOver() function in your Start() function, it’ll begin to flicker when you enter Play mode.

However, to make the Game Over screen part of your game flow, you’ll need to know the conditions in your game that lead to this Game Over screen. Once a condition is met, you’ll need a reference to the UIManagerScript and call its public method DisplayGameOver().

If you don’t like the retro effect, you can always make another effect with Coroutines like a changing color effect. Coroutines are incredibly powerful, so continue to explore them!

--

--