Hi all,
whats the proper way of pausing a game? ive tried a couple of things though i cant seem to NOT have the the menu pause with it. Ive had a good look around on the net though i cant seem to work it out.
using UnityEngine;
using System.Collections;
public class Pause : MonoBehaviour {
private bool isPaused = false;
public GameObject menu; // Assign in inspector
void Update ()
{
if (Input.GetButtonDown("Start"))
{
if (isPaused)
{
///PAUSED
Time.timeScale = 1;
isPaused = false;
}
else
{
//NOT PAUSED
Time.timeScale = 0;
isPaused = true;
}
}
menu.SetActive(isPaused);
}
}
Thanks Jacky, Where do i actually place that? i tried doing the below however i was getting errors: void OnGUI() { { Time.timeScale = 1; }
– FlashXyou can make a public function like bool pause = false; public void PauseFunction() { if(!pause) { Time.timeScale = 0.0f; pause = true; } else { Time.timeScale = 1.0f; pause = false; } } and after call the function with the button click
– Jacky-Marley