0% found this document useful (0 votes)
11 views

Countdown Unity

The document describes a countdown script for Unity that uses coroutines to count down from a number and display it on a text object before setting the text to 'Go!' and deactivating the text object. It also includes pause and resume functions to adjust the timescale.

Uploaded by

Mateo Teodor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Countdown Unity

The document describes a countdown script for Unity that uses coroutines to count down from a number and display it on a text object before setting the text to 'Go!' and deactivating the text object. It also includes pause and resume functions to adjust the timescale.

Uploaded by

Mateo Teodor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

using System.

Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CountDown : MonoBehaviour
{

private void Start()


{
StartCoroutine(CountToStart());
}
public int CountDownToStart;
public Text countDisplay;
IEnumerator CountToStart()
{
while (CountDownToStart > 0)
{
countDisplay.text = CountDownToStart.ToString();
yield return new WaitForSeconds(1f);
CountDownToStart--;
}
countDisplay.text = "Go!";

yield return new WaitForSeconds(1f);


countDisplay.gameObject.SetActive(false);

Time.timeScale = 1;
}

void Pause()
{
Time.timeScale = 0;
}
void Resume()
{
Time.timeScale = 1;
}
}

You might also like