Hi Guys,
Hopefully someone will be able to figure this one out. I have added a Pause function to the Glitch Garden game I am creating however when the pause button is pressed the text does not display on top of the defenders / attackers in the core game area. Does anyone have an idea on how to do this. Also the pause text doesn’t display on the first Pause event though will on the 2nd. I have done this through to sprites with 2d box colliders on them. Which both have this script attached. I tried changing the sprite on a single game object and this caused issues with scaling of the sprite would reduced the size of the 2d box collider. I have tried playing with the z index of its transform without much luck.
Thanks Pete
public class PauseButton: MonoBehaviour
{
public Text pausedText;
public static bool pause = false;
public GameObject playBtn;
public GameObject pauseBtn;
void Start()
{
pausedText.enabled = false;
}
public void PauseGame() {
pause = !pause;
if (pause) {
Time.timeScale = 0f;
pausedText.enabled = true;
pauseBtn.SetActive(false);
playBtn.SetActive(true);
} else {
Time.timeScale = 1f;
pausedText.enabled = false;
playBtn.SetActive(false);
pauseBtn.SetActive(true);
}
}
void OnMouseDown() {
PauseGame ();
}
}
