Cursor does not show up in pause menu. C#,Cursor isn't showing up in Pause Menu when game is built. C#
So I have pause menu in my FPS game in unity 3d. when game is not build and I press escape (my bind for unity to show pause menu) it works fine and shows pause menu but I cannot press the buttons until I press "C". and after I press "C" and then resume button in the pause menu game just freezes. (though fps controller still works).
When I build the game and press escape menu shows up, but cursor does not and then I press "C" and resume button and then game freezes. (though fps controller still works).
this is the script: using UnityEngine; using System.Collections; using UnityStandardAssets.Characters.FirstPerson; using UnityEngine.SceneManagement; public class PauseGame : MonoBehaviour { public Transform canvas; public Transform Player; public static bool GamePaused = false; public static bool cursorLocked = true; [SerializeField] private GameObject pauseMenuUI; [SerializeField] private bool isPaused; // Update is called once per frame void Update () { if (Input.GetKeyDown(KeyCode.Escape)) { Pause(); } if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { if (hit.collider != null) { Debug.Log(hit.collider.gameObject.name); } } } } public void Pause() { if (canvas.gameObject.activeInHierarchy == false) { canvas.gameObject.SetActive(true); Time.timeScale = 0; Player.GetComponent<FirstPersonController>().enabled = false; } else { canvas.gameObject.SetActive(false); Time.timeScale = 1; Player.GetComponent<FirstPersonController>().enabled = true; } } void UpdateCursorLock() { if (!GamePaused && Input.GetKeyDown(KeyCode.Escape)) { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; cursorLocked = false; } else if (GamePaused) { Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; cursorLocked = true; } } public void DeactivateMenu() { Time.timeScale = 1; AudioListener.pause = false; pauseMenuUI.SetActive(false); isPaused = false; } public void GoToMainMenu() { Time.timeScale = 1f; SceneManager.LoadScene("MainMenu"); } public void Exit() { Application.Quit(); Debug.Log("Quit"); } } 
,So I have a problem with my pause menu... when the game is not built and I press escape (my bind for unity to take out pause menu) it works fine, and shows me the pause menu, but I cannot press any buttons in the menu. This problem gets fixed when I press "C" but then, when I press resume button in the pause menu, game is frozen...
When I build the game and press escape cursor does not show up at all... and then same thing happens I press "C" then Resume button, pause menu goes away but game is frozen... does anyone have any solutions for this?
This is the script :
 using UnityEngine;
 using System.Collections;
 using UnityStandardAssets.Characters.FirstPerson;
 using UnityEngine.SceneManagement;
 
 public class PauseGame : MonoBehaviour {
     public Transform canvas;
     public Transform Player;
     public static bool GamePaused = false;
     public static bool cursorLocked = true;
 
     [SerializeField] private GameObject pauseMenuUI;
 
     [SerializeField] private bool isPaused;
 
 
 
 
     // Update is called once per frame
     void Update () {
         if (Input.GetKeyDown(KeyCode.Escape))
         {
             Pause();
         }
         if (Input.GetMouseButtonDown(0))
         {
             RaycastHit hit;
             Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
 
             if (Physics.Raycast(ray, out hit))
             {
                 if (hit.collider != null)
                 {
                     Debug.Log(hit.collider.gameObject.name);
                 }
             }
         }
     }
     public void Pause()
     {
         if (canvas.gameObject.activeInHierarchy == false)
         {
             canvas.gameObject.SetActive(true);
             Time.timeScale = 0;
             Player.GetComponent<FirstPersonController>().enabled = false;
         }
         else
         {
             canvas.gameObject.SetActive(false);
             Time.timeScale = 1;
             Player.GetComponent<FirstPersonController>().enabled = true;
         }
     }
 
     void UpdateCursorLock()
     {
         if (!GamePaused && Input.GetKeyDown(KeyCode.Escape))
         {
             Cursor.lockState = CursorLockMode.None;
             Cursor.visible = true;
             cursorLocked = false;
 
         }
         else if (GamePaused)
         {
             Cursor.lockState = CursorLockMode.Locked;
             Cursor.visible = false;
             cursorLocked = true;
         }
     }
 
     public void DeactivateMenu()
     {
         Time.timeScale = 1;
         AudioListener.pause = false;
         pauseMenuUI.SetActive(false);
         isPaused = false;
     }
 
     public void GoToMainMenu()
     {
         Time.timeScale = 1f;
         SceneManager.LoadScene("MainMenu");
     }
 
     public void Exit()
     {
         Application.Quit();
 
         Debug.Log("Quit");
     }
 
 }
 
 
              Your answer