Retro Element in Today’s Environment

One of the elements people assigned to retro games in the past is the flashing “Game Over” screen once the player has died. Fortunately for us, in Unity, it’s easy to set up within Unity’s own UI system.

Setting up the UI System

In order to get the text to show up, we must first generate a Canvas. By right-clicking in the Hierarchy, going down to UI, and selecting Canvas, Unity will generate a Canvas game object and place it in the Hierarchy.

Once generated, you then can create a Text UI element by using the same method as above, but now choosing Text rather than Canvas.

Getting it to show Game Over

After generating a Text UI element, it will be child onto the Canvas game object. As a result, you’ll have to expand the Canvas game object to see the Text element you just created. Once you select the Text element, check out its properties:

First, because this will display “Game Over”, reposition the Text element towards the middle of the screen. You can complete this by adjusting the Pos X and Pos Y elements as well as the Anchors.

Once you’re done repositioning the element, it’s time to increase the size. However, it’s easier to type what you want before resizing it, so head towards the Text section of the Inspector.

Here, you can type in anything you want, but because this is for the game over screen, it’s better to keep it simple as “Game Over”. In addition, you can modify the font, size, color, and overflow of the text itself. For me, I’ve chosen

  • Arial Font
  • 100 Font
  • Overflow for both Horizontal and Vertical Overflow
  • White as the font color

The Finishing Touches

Once you created and modified your Text element for the Game Over screen, disable it by unchecking the check box located on the top of the Inspector screen. By unchecking it, you’re essentially hiding it once the game starts.

Last, but not least, it’s time to write some code to enable this effect. By using a coroutine, you can give it the effects of it flashing without actually flashing it. You will achieve this by enabling and disabling the Text element.

IEnumerator GameOver()
{
while (true)
{
_gameOverText.gameObject.SetActive(true);
yield return new WaitForSeconds(0.5f);
_gameOverText.gameObject.SetActive(false);
yield return new WaitForSeconds(0.5f);
}
}

You now have a simple yet effective retro effect as your Game Over screen!

--

--

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