Hi, Time.timeScale=0 is not working when I use in the game over menu. The game still can run when the menu popup. I hope that someone can help me.Thanks.
Here the code:
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class EventHandler : MonoBehaviour {
public string sceneName;
private bool pauseEnable;
public LevelManager levelManager;
public GameObject GameOverPanel;
public GameObject WinPanel;
// Use this for initialization
void Start()
{
HideGameOverMenu();
HideWinMenu();
//pauseMenu.SetActive(false);
levelManager = FindObjectOfType<LevelManager>();
}
// Update is called once per frame
void Update()
{
// if (Application.platform == RuntimePlatform.Android)
// {
// if (Input.GetKey(KeyCode.Escape))
// {
// SceneManager.LoadScene(sceneName);
//
// }
// }
}
public void SelectScene(string Scene)
{
SceneManager.LoadScene(Scene);
}
public void Restart()
{
levelManager.RespawnPlayer();
}
public void HideGameOverMenu()
{
GameOverPanel.SetActive(false);
}
public void ShowGameOverMenu()
{
GameOverPanel.SetActive(true);
Time.timeScale = 0;
}
public void HideWinMenu()
{
WinPanel.SetActive(false);
}
public void ShowWinMenu()
{
WinPanel.SetActive(true);
Time.timeScale = 0;
}
}