PracProg/Assets/Scripts/Pause.cs

36 lines
689 B
C#
Raw Permalink Normal View History

2021-02-04 19:49:39 +01:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Pause : MonoBehaviour
{
Image img;
//references
public Sprite playSprite;
public Sprite pausedSprite;
private void Start()
{
img = GetComponent<Image>();
}
public void OnPausedGame()
{
if(GameManager.gameIsPaused == false)
{
Time.timeScale = 0;
img.sprite = playSprite;
GameManager.gameIsPaused = true;
}
else
{
Time.timeScale = 1;
img.sprite = pausedSprite;
GameManager.gameIsPaused = false;
}
}
}