protected bool paused;
void OnPauseGame ()
{
paused = true;
}
void OnResumeGame ()
{
paused = false;
}
void Update ()
{
if (!paused) {
Time.timeScale=1;
}
if(paused)
{
Time.timeScale=0;
}
}
protected bool paused;
void OnPauseGame ()
{
paused = true;
}
void OnResumeGame ()
{
paused = false;
}
void Update ()
{
if (!paused) {
Time.timeScale=1;
}
if(paused)
{
Time.timeScale=0;
}
}
Hi guys, the pause canvas is showing but the game does not pause. any ideas?
using UnityEngine;
public class Puase_menu : MonoBehaviour {
Input_m im;
public GameObject pause_menu;
void Awake ()
{
im = GameObject.Find("Game_Manager").GetComponent<Input_m>();
}
void Update ()
{
if (im.PressedDown ("Pause"))
{
pause_menu.SetActive(true);
Time.timeScale = 0;
}
else
{
Time.timeScale = 1;
}
}
}
Hi You must disable Error Pause from the Console
If you want to make a pause menu, simply use an if statement in the update function that detects if paused is false, if so continue as normal. Else display the pause screen. Add a mouse click detection for a pause button or set the esc button to switch paused around.
As @Martin Schultz says:
I think that code can be like this:
public bool paused = false;
public void Update()
{
if(Input.GetKeyDown("p"))
{
if(paused == false)
{
Time.timeScale = 0f;
paused = true;
}
else
{
Time.timeScale = 1f;
paused = false;
}
}
}
I hope that this works.