Well, I have a button "menu" on the UI and i want press it to show a canvas. I have this code: Code (CSharp): 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
Code (csharp): (Input.GetButtonDown("menu")) this refers to a keyboard button press... how to setup UI buttons: https://unity3d.com/learn/tutorials/modules/beginner/ui/ui-button?playlist=17111
Sooo the code will be: Code (CSharp): using UnityEngine; using System.Collections; public class menuScript : MonoBehaviour { public GameObject PauseUI; private bool paused = false; void Start () { PauseUI.SetActive(false); } public void onClick() { paused = !paused; if (paused) { PauseUI.SetActive(true); Time.timeScale = 0; } if (!paused) { PauseUI.SetActive(false); Time.timeScale = 1; } } }