Reputation: 509
Whenever I press escape button,my game paused and gui shows but my health bar at canvas does not pause.. here is my code.. any suggestions
using UnityEngine;
using System.Collections;
public class PauseMenu : MonoBehaviour {
bool paused = false;
void Update()
{
if(Input.GetButtonDown("pauseButton"))
paused = togglePause();
}
void OnGUI()
{
if(paused)
{
if(GUI.Button(new Rect(Screen.width/2- 100,Screen.height/2+1,180,40),"Resume Game"))
paused = togglePause();
}
}
bool togglePause()
{
if(Time.timeScale == 0f)
{
Time.timeScale = 1f;
return(false);
}
else
{
Time.timeScale = 0f;
return(true);
}
}
}
Upvotes: 0
Views: 70
Reputation: 2989
Time.timeScale = 0
doesn't stop everything.
If it would stop everything your game would freeze and be completly unresponsive. If your damaging is called e.g. in Update
and doesn't use Time.deltaTime
it will still be called.
Upvotes: 1