Hi guys,
I need help with my Pause Menu I created. I made a script where if you hit the Escape button, the pause menu will appear and they’ll be two buttons; home and resume. My mouse cursor hovers over the buttons and the two buttons should be highlighted and work, however it doesn’t work properly.
What I mean by that is, the buttons do not become highlighted nor do they work. If I try to click on the buttons, my mouse will disappear and I can’t do anything. I have to hit the Escape key to exit out of the Pause Menu and back into my scene. Then if I hit the Escape key again the Pause Menu will appear and now if I hover my mouse over the buttons they become highlighted and if I can click on any of them they start working. How do I fix this issue?
Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.Characters.FirstPerson;
using UnityEngine.SceneManagement;
public class PauseMenu : MonoBehaviour {
public Transform PauseCanvas;
public Transform Player;
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.Escape))
{
Resume();
}
}
public void Resume()
{
if (PauseCanvas.gameObject.activeInHierarchy == false)
{
PauseCanvas.gameObject.SetActive(true);
Time.timeScale = 0;
Player.GetComponent<FirstPersonController>().enabled = false;
}
else
{
PauseCanvas.gameObject.SetActive(false);
Time.timeScale = 1;
Player.GetComponent<FirstPersonController>().enabled = true;
}
}
public void Home()
{
SceneManager.LoadSceneAsync("Home");
}
}