Displaying an end game message

EndGameMessage680x340To display a message when the game ends you need to add a few lines of code to the game script that you are using, in this example “ShowGameOverMessageGame”. Essentially, you add a event handler to the OnGameOver event that displays a message depending on the configuration.


Here is how the code looks:

if (showWinnerID)
 manager.OnGameOver += OnGameOver;
 if (customText == string.Empty)
 customText = "Game Over!\nPress Space to restart";
 manager.OnGameOver += () => ShowMessage(customText);

The field manager.OnGameOver is an event that fires when the game ends.

The two methods used are these:

private void OnGameOver()
 var winner = manager.Winners.First();
 "The winner is {0}. \nPress  to play again.", winner.PlayerID));
 private void ShowMessage(string message)
 text.text = message;

The rules of this game are the same as the Victory Conditions examples.

To check out this example:

  • Import Abstract Strategy in a new project.
  • Import the package below into the same project.
  • Open the ShowMessageGameOver scene.


Scroll to Top