Hello Unity Answers,
I am trying to return to the Mainmenu scene once the game has finished. I have created a Mainmenu & gameover scene.
The gameover scene is made up of UI text which I have added a Button script to make them clickable buttons. I want the player to click PLAY AGAIN & EXIT to return to the main menu or exit the game.
All help and suggestions welcome.
Gameover scene
Main menu scene
using System;
using System.Collections.Generic;
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Gameover : MonoBehaviour {
private int count;
public Text countText;
public Button PlayAgainText;
public Button exitText;
public void UIActions (string loadActions)
{
if (loadActions == "Play Again")
{
Application.LoadLevel ("3");
}
}
void Start ()
{
DontDestroyOnLoad (gameObject);
count = 0;
SetCountText ();
PlayAgainText = PlayAgainText;
exitText = exitText;
if (GUI.Button (new Rect (20, 100, 100, 30), "1976"))
{
Destroy (this.gameObject);
count = count = 0;
SetCountText ();
}
}
void SetCountText()
{
countText.text = "Score: " + ValuesHolder.answersCount.ToString();
ValuesHolder.answersCount++;
}
public void StartLevel()
{
Application.LoadLevel (3);
}
public void ExitGame()
{
Application.Quit ();
}
}