I have a first person game that is controlled by the mouse, and I have a pause screen that pauses the game and presents the player with buttons to keep playing, restart, or go to the main menu. But right now when I pause you can still look around the game area with the mouse and you can’t click any of the buttons since the mouse is still being used for where to look. How can I fix this so that the player can see the mouse and use it to click the buttons. Here’s my UI code for pause:
public class UIManager : MonoBehaviour {
GameObject[] pauseObjects;
// Use this for initialization
void Start () {
Time.timeScale = 1;
pauseObjects = GameObject.FindGameObjectsWithTag("ShowOnPause");
hidePaused();
}
// Update is called once per frame
void Update () {
//uses the p button to pause and unpause the game
if(Input.GetKeyDown(KeyCode.P))
{
if(Time.timeScale == 1)
{
Time.timeScale = 0;
showPaused();
} else if (Time.timeScale == 0){
Debug.Log ("high");
Time.timeScale = 1;
hidePaused();
}
}
}
//Reloads the Level
public void Reload(){
Application.LoadLevel(Application.loadedLevel);
}
//controls the pausing of the scene
public void pauseControl(){
if(Time.timeScale == 1)
{
Time.timeScale = 0;
showPaused();
} else if (Time.timeScale == 0){
Time.timeScale = 1;
hidePaused();
}
}
//shows objects with ShowOnPause tag
public void showPaused(){
foreach(GameObject g in pauseObjects){
g.SetActive(true);
}
}
//hides objects with ShowOnPause tag
public void hidePaused(){
foreach(GameObject g in pauseObjects){
g.SetActive(false);
}
}
//loads inputted level
public void LoadLevel(string level){
Application.LoadLevel(level);
}
}