So after watching a video I think I understand how this code should work and setactive does not turn off my pause menu I have the pauseUI selected as the object rigged to the main camera and nothing happens perhaps the tutorial I was watching is outdated or it’s because I have more then one scene?
My problem isn’t with stopping time it’s with setting my canvas to false so that I don’t have a pause menu in the middle of my screen.
This is my first project in unity so I don’t really understand much in terms of programming.
So it turns out the weirdest fix I’ve done was changing my void’s to FixedUpdate save then change it back… I don’t know what caused it to work or if my void’s weren’t right before but it’s working.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Pause : MonoBehaviour {
public GameObject pauseUI;
private bool paused = false;
void Start(){
pauseUI.SetActive(paused);
}
void Update(){
if (Input.GetButtonDown ("Pause")) {
paused = true;
}
if (paused == true) {
pauseUI.SetActive (true);
Time.timeScale = 0.0f;
}
if (paused == false){
pauseUI.SetActive (false);
Time.timeScale = 1;
Debug.Log ("I am Working");
}
}
}