Question by
DiogoAraujo · Apr 11, 2020 at 01:12 PM ·
c#bugsceneprogrammingpause
PAUSE MENU - - If i press "w" and "space change scene..
hello guys, I have a annoying bug that I can't find out what it is. I open the pause menu, and press continue, it exits the pause menu and continues the normal game. but if you press the "W" and "space" keys at the same time, it changes the scene. but if you don’t open the menu it doesn’t happen and I don't have any code to do that. it happens for no reason. any ideia????
this is the code:
public class PauseMenu : MonoBehaviour { public static PauseMenu instance;
public GameObject pauseMenu;
public GameObject player;
public bool isAtivePauseMenu = false;
//sons
public AudioSource audioSButtoon;
public AudioClip buttonHiglightSound;
void Awake()
{
if (instance == null)
{
instance = this;
}
}
void Start()
{
StartCoroutine(WaitToCall());
pauseMenu = UIManager.instance.pauseMenu;
//paineis de menu
isAtivePauseMenu = false;
}
void Update()
{
if (!isAtivePauseMenu)
{
if (Input.GetKeyDown(KeyCode.Escape))
{
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
Pause();
}
}
}
public void Pause()
{
player.GetComponent<FirstPersonController>().enabled = false;
pauseMenu.GetComponent<Animator>().SetBool("isActive", true);
Time.timeScale = 0f;
}
public void Resume()
{
Time.timeScale = 1f;
isAtivePauseMenu = false;
player.GetComponent<FirstPersonController>().enabled = true;
pauseMenu.GetComponent<Animator>().SetBool("isActive", false);
}
public void MainMenu()
{
//SceneManager.LoadScene("MainMenu");
// Time.timeScale = 1f;
}
public void quit()
{
Debug.Log("Fechou o jogo");
Application.Quit();
}
public void HoverSound()
{
audioSButtoon.PlayOneShot(buttonHiglightSound);
}
IEnumerator WaitToCall()
{
//prucura player no inicio
yield return new WaitForSeconds(1.2f);
player = UIManager.instance.player;
}
}
Comment
Your answer
Follow this Question
Related Questions
Help with pause menu? 0 Answers
Sound in Unity is not working! WHY? 0 Answers
Using coroutine and texture array to randomly associate textures? 1 Answer
Input Command Issues 0 Answers
UNET Multiple online scenes 0 Answers