like in the title,I’m making a simple game that have 60 sec. to grab item as much as you can and when the timer is out,I want to play animation that pop the restart buttom up anyone can help me about this? thanks
this is my Timer code.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Timer : MonoBehaviour
{
public int timeLeft = 1;
public Text countdownText;
Animator anim;
void Awake()
{
anim = GetComponent<Animator>();
}
void Start()
{
StartCoroutine("LoseTime");
}
void Update()
{
countdownText.text = ("TimeLeft : " + timeLeft + " Sec.");
if (timeLeft <= 0)
{
anim.SetTrigger ("GameOver");
StopCoroutine("LoseTime");
countdownText.text = ("Time's UP!!!!");
}
}
IEnumerator LoseTime()
{
while (true)
{
yield return new WaitForSeconds(1);
timeLeft--;
}
}
}