Now that we have an exception that is thrown when we lose the game, let's handle it safely:
- Update GameBehavior with the following code and lose the game again:
public class GameBehavior : MonoBehaviour, IManager
{
// ... No variable changes needed ...
// ... No changes needed in Start
Initialize,
Print,
or LogWithDelegate ...
void OnGUI()
{
// ... No other changes to OnGUI needed ...
if(showLossScreen)
{
if (GUI.Button(new Rect(Screen.width / 2 - 100,
Screen.height / 2 - 50, 200, 100), "You lose..."))
{
// 1
try
{
Utilities.RestartLevel(-1);
debug("Level restarted successfully...");
}
// 2
catch (System.ArgumentException e)
{
...