51 Unity UI Tutorial: Game Over Screen & Restart Button

Опубликовано: 22 Март 2026
на канале: Sudheendra S G
42
2

00:00 Intro + What we’ll build (Game Over + Restart)
01:04 Open project / Create UI_Prototype5 (URP 3D)
01:33 Download Patreon package + Sartwick layout
02:02 Cleanup (Remove Readme, delete input actions)
02:22 Apply Sartwick layout + Import unitypackage
03:02 Open UI_Prototype scene + Delete sample scene
03:15 Scene navigation tips (F key, 2D view)
03:25 Recreate Target Layer + Assign to prefabs/GameManager
04:10 Create Game Over UI Panel
05:01 Game Over Text (TMP, Indie Flower, styling)
06:01 Restart Button (size, text, highlight color)
07:01 Hide panel on Start + Link panel to GameManager
08:46 Create GameOver() function + Trigger from sensor hit
10:40 Fix logic: Only GOOD objects trigger game over
12:47 Stop spawning + Disable clicks when game is over
16:21 Restart system using SceneManager (reload active scene)
18:03 Hook Restart button OnClick → RestartGame()
18:44 Final test + Next session preview (difficulty levels)

Get free resources for this course from the below patreon link

  / 145923169  

Finished Games can be tested with the link below

https://play.unity.com/en/user/414168...

In this Unity UI Prototyping Game (Session 51), we complete a fully playable loop by adding a Game Over screen and a Restart button that resets everything and starts the game again.

Right now, the player can keep scoring even after losing — so in this session we fix that properly:
✅ Show Game Over UI only when the player actually loses
✅ Stop spawning when the game ends
✅ Disable click/explosion events after game over
✅ Add a Restart button using a UI Button OnClick event listener
✅ Reload the active scene using SceneManager for a clean restart

✅ What you will learn in this session

How UI Buttons act as event listeners

Creating a Game Over Panel using Unity UI + TextMeshPro

Making UI appear only when needed (SetActive(false/true))

Adding GameOver() logic inside GameManager

Triggering Game Over only for Good targets using a boolean flag (isGood)

Stopping coroutines/spawning using while(!isGameOver)

Blocking input/gameplay after Game Over

Restarting the game with:

using UnityEngine.SceneManagement;

SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);

Wiring the Restart button to a public method from the Inspector

📦 Project & Package Files (Patreon)

If you're following along, download the session package from the Patreon link in the description:

51_UIGameOverStar.unitypackage

Optional: Sartwick_Layout.wlt (for matching the same editor layout)

🧠 Key Scripts Used

GameManager.cs

public GameObject gameOverPanel;

public bool isGameOver = false;

public void GameOver()

public void RestartGame()

Target.cs

public bool isGood;

Trigger Game Over only if isGood == true

Disable OnHit logic when GameManager.instance.isGameOver == true

🔥 Next Session Preview

In the next session, we’ll add difficulty levels to the game to make it more fun and challenging.

If this helped you, like, subscribe, and share — it supports this Junior Programmer Series a lot.