My button keep working even when I deactivated it

My button keep working even when I deactivated it. Can someone explain me why?

My Script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class MenuDePause : MonoBehaviour
{

public static bool GameIsPaused = false;

public GameObject PauseMenuUI;
public GameObject ResumeButtonUI;
public GameObject MenuButtonUI;
public GameObject QuitButtonUI;

// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{

if (Input.GetKeyDown(KeyCode.P))
{
if (GameIsPaused)

{
Resume();
}
else
{
Pause();
}

}

}

public void Resume()
{
Time.timeScale = 1f;
GameIsPaused = false;

PauseMenuUI.SetActive(false);
ResumeButtonUI.SetActive(false);
MenuButtonUI.SetActive(false);
QuitButtonUI.SetActive(false);
}

void Pause()
{
Time.timeScale = 0f;
GameIsPaused = true;

PauseMenuUI.SetActive(true);
ResumeButtonUI.SetActive(true);
MenuButtonUI.SetActive(true);
QuitButtonUI.SetActive(true);

}

public void Menu()
{
SceneManager.LoadScene(“MenuPrincipal”);
UnityEngine.Debug.Log(“Carregando Menu”);
}

public void Quit()
{
UnityEngine.Debug.Log(“Saindo do Jogo”);
Application.Quit();
UnityEditor.EditorApplication.isPlaying = false;
}

}

Please use code tags: Using code tags properly

How to report problems productively in the Unity3D forums:

http://plbm.com/?p=220

Help us to help you.

1 Like