countdown script in unity

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class  Timer : MonoBehaviour
{
    public int timeLeft = 20;
    public Text countdownText;
    GameObject timeuptext;
    GameObject timeend;
    public int timeCountdownPlays;
    public AudioClip CountDownSound;
    public AudioSource SoundSource;
    

    
    void Start()
    {
        timeuptext = GameObject.Find("TimeUp");
        timeuptext.SetActive(false);
        timeend = GameObject.Find("Timer Text");
        StartCoroutine("LoseTime");
        SoundSource.clip = CountDownSound;
    }

  
    void Update()
    {
       
        countdownText.text = ("" + timeLeft);
            

        if (timeLeft <= 0)
        {
            timeuptext.SetActive(true);
            timeend.GetComponent<Text>().enabled = false;
            
        }

        if (timeLeft == timeCountdownPlays)
        {
            SoundSource.Play();
        }
            
            
        
      
       
    }

    IEnumerator LoseTime()
    {
        while (true)
        {
            yield return new WaitForSeconds(1);
            timeLeft--;
        }
    }
}

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
unity countdown timer to start unity c# countdown to a datetime unity c# countdown timer unity make countdown timer unity c# countdown to a date unity datetime countdown how to display a countdown in unity count down timer unity countdown timer in unity countdown script while unity countdown script unity countdown timer unity code countdown unity with effects unity countdown animation unity countdown clock unity simple time countdown unity countdown function with function unity start countdown countdown timer unity how to make countdown timer in unity how to count the times pressed in unity unity countdown timer unity countdown timer minutes and seconds count down timer in unity countdown unity countdown unity c# time.time countdown unity countdown in unity unity 2d countdown timer script c# unity deltatime countdown unity create timer how to make a countdown time unity how to make x second countdown unity unity how to set timer Unity Count down timer C# how to make timer uniyt unity create a timer how countdown timer unity creating a timer unity unity set timer count down timer unity3d timer in unity3d unity countdown timer script c# create timer in unity coutdown timer in unity how to make a countdown timer in unity how to make timer in unity how to set a timer unity timer in unity unity how to make a timer countdown how to display countdown timer in time.delta time c# unity unity how to make a countdown timer Unity timer c# countdown timer unity how to set a timer in unity c# unity set a timer unity show timer time how to do countdown unity&ugrave; creating a timer in unity timer unity c# start timer in unity dani dash timer unity code unity c# do something on a count down how to make countdown unity make a timer unity how to make a timer in unity how to make a countdown unity timer script unity countdown script in unity
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source