Hi all,
I have three buttons on my main menu. If I click either Play Game or Story so far, they cease to work again after that. However if I click quit, I can click that one as many times as I want and it works perfectly.
Here is my code:
using UnityEngine;
using UnityEngine.SceneManagement;
public class MenuManager : MonoBehaviour {
public GameObject story;
private float targetTime = 63.0f;
private bool storyOn;
void Update()
{
if(storyOn)
{
targetTime -= Time.deltaTime;
story.SetActive(true);
if (targetTime <= 0.0f)
story.SetActive(false);
}
}
public void StartGame () // Called upon when player clicks play
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
public void Story() // Called upon when player clicks story
{
if (story.activeInHierarchy == false)
{
storyOn = true;
}
else
story.SetActive(false);
}
public void QuitGame() // Called upon when player clicks on quit
{
Debug.Log("Application Quit!"); // Console will log message saying application quit
Application.Quit(); // The application will now quit
}
}
Any help is greatly appreciated!