Well, I have a button “menu” on the UI and i want press it to show a canvas. I have this code:
using UnityEngine;
using System.Collections;
public class menuScript : MonoBehaviour {
public GameObject PauseUI;
public GameObject menu;
private bool paused = false;
void Start () {
PauseUI.SetActive(false);
}
void Update () {
if (Input.GetButtonDown("menu")) {
paused = ! paused;
}
if (paused)
{
PauseUI.SetActive(true);
Time.timeScale = 0;
}
if (!paused)
{
PauseUI.SetActive(false);
Time.timeScale = 1;
}
}
}
When I asociated the “menu” button with my public gameobject menu, but when i press it canvas still hiden