Mouse dont move in pausemenu,Can move with mouse in pause menu
Hello, I have some problems with pause menu. When i pause the game, I see the cursor, but it wont move(cursor dont move) And I cant resume or exit the game with my buttons
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;
public class PauseMenu : MonoBehaviour {
[SerializeField] private GameObject pauseMenuUI;
[SerializeField] private bool isPaused;
void Update()
{
if(Input.GetKeyDown(KeyCode.Escape))
{
isPaused = !isPaused;
}
if(isPaused)
{
ActivateMenu();
}
else
{
DeactivateMenu();
}
}
void ActivateMenu()
{
GameObject.Find("Player").GetComponent<PlayerMovement>().enabled = false;
Time.timeScale = 0;
AudioListener.pause = true;
pauseMenuUI.SetActive(true);
Cursor.visible = true;
}
public void DeactivateMenu()
{
GameObject.Find("Player").GetComponent<PlayerMovement>().enabled = true;
Time.timeScale = 1;
AudioListener.pause = false;
pauseMenuUI.SetActive(false);
isPaused = false;
Cursor.visible = false;
}
public void ExitToMenu()
{
SceneManager.LoadScene(0);
}
}
Thanks for help,Hello, I made simple pause menu but when I pause that game I cant move with cursor(with mouse) here is my script: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement;
public class PauseMenu : MonoBehaviour { [SerializeField] private GameObject pauseMenuUI;
[SerializeField] private bool isPaused;
void Update()
{
if(Input.GetKeyDown(KeyCode.Escape))
{
isPaused = !isPaused;
}
if(isPaused)
{
ActivateMenu();
}
else
{
DeactivateMenu();
}
}
void ActivateMenu()
{
GameObject.Find("Player").GetComponent<PlayerMovement>().enabled = false;
Time.timeScale = 0;
AudioListener.pause = true;
pauseMenuUI.SetActive(true);
Cursor.visible = true;
}
public void DeactivateMenu()
{
GameObject.Find("Player").GetComponent<PlayerMovement>().enabled = true;
Time.timeScale = 1;
AudioListener.pause = false;
pauseMenuUI.SetActive(false);
isPaused = false;
Cursor.visible = false;
}
public void ExitToMenu()
{
SceneManager.LoadScene(0);
}
}
thanks for help...
Your answer
Follow this Question
Related Questions
Problem with camera loading different scenes 0 Answers
Pausing a game 2 Answers
How can I make sure that the game is selected after closing out of a pause menu? 0 Answers
How to Pause Menu with Animating Button Works? 1 Answer
Pause Menu 1 Answer