countdown script unity
C#
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--;
}
}
}
Also in C#:
- Title
- c# create a text file
- Category
- C#
- Title
- c# expression func automatically select return type
- Category
- C#
- Title
- how to compare datetime in c#
- Category
- C#
- Title
- C# Console multi language
- Category
- C#
- Title
- linq c# or
- Category
- C#
- Title
- C# loop through array of objet
- Category
- C#
- Title
- c# error "The name 'ViewBag' does not exist in the current context"
- Category
- C#
- Title
- how to reference scripts in other scenes unity
- Category
- C#
- Title
- using mediamanager how to play mp3 files
- Category
- C#
- Title
- split on uppercase c#
- Category
- C#
- Title
- check connection c#
- Category
- C#
- Title
- asp.net render control to string
- Category
- C#
- Title
- cannot apply indexing with to an expression of type 'object'
- Category
- C#
- Title
- how to make a game
- Category
- C#
- Title
- change Backcolor c#
- Category
- C#
- Title
- json tiers dot in name c#
- Category
- C#
- Title
- wpf c# select folder path
- Category
- C#
- Title
- C# get all child classes of a class
- Category
- C#
- Title
- c# get all class properties
- Category
- C#
- Title
- c# get pc ip address
- Category
- C#
- Title
- no entity framework provider found for the ado.net provider with invariant name
- Category
- C#
- Title
- membership get user id
- Category
- C#
- Title
- c# bitmap to Image
- Category
- C#
- Title
- c# string list contains
- Category
- C#
- Title
- check if enabled unity
- Category
- C#
- Title
- linq c# object except two lists
- Category
- C#
- Title
- can send but cannot receive email dreamhost email
- Category
- C#
- Title
- bytes size c#
- Category
- C#
- Title
- use newtonsoft json to clone object
- Category
- C#
- Title
- how to pass object as test case in nunit c#
- Category
- C#
- Title
- c# get foreground window
- Category
- C#
- Title
- how to clear console in c#
- Category
- C#
- Title
- windows form rounded corners
- Category
- C#
- Title
- csharp attributes as generics constraints
- Category
- C#
- Title
- c# how to run external program with args
- Category
- C#
- Title
- unity rotate object c#
- Category
- C#
- Title
- c# polymorphism
- Category
- C#
- Title
- how to clear console through script unity
- Category
- C#
- Title
- how to make a string a list of characters c#
- Category
- C#
- Title
- unity c# is not equal to
- Category
- C#
- Title
- c# filesystemwatcher double events
- Category
- C#
- Title
- Rigidbody.addforce
- Category
- C#
- Title
- loop over enum values
- Category
- C#
- Title
- C# function return datareader
- Category
- C#
- Title
- unity key detection
- Category
- C#
- Title
- add mime type for woff in web.config
- Category
- C#
- Title
- .net core convert keycollection to array
- Category
- C#
- Title
- how to create public variable in c#
- Category
- C#
- Title
- c# windows forms draw pixel
- Category
- C#
- Title
- wpf get name of clicked element
- Category
- C#
- Title
- c# push numbers to array
- Category
- C#
- Title
- unity rotate around point
- Category
- C#
- Title
- player script unity
- Category
- C#
- Title
- c# how to add newline on text box
- Category
- C#
- Title
- access dic by key c#
- Category
- C#
- Title
- decimals not stored in azure tables
- Category
- C#
- Title
- how to add to an array c#
- Category
- C#
- Title
- Request.ServerVariables["HTTP_X_FORWARDED_FOR"] get only one ipaddress
- Category
- C#
- Title
- c# double value with 2 decimal places
- Category
- C#
- Title
- c# array inst working
- Category
- C#
- Title
- convert double to currency c#
- Category
- C#
- Title
- unity button interactable
- Category
- C#
- Title
- whats a string
- Category
- C#
- Title
- add object to list c#
- Category
- C#
- Title
- countdown script in unity
- Category
- C#
- Title
- how to parse a string to an integer c#
- Category
- C#
- Title
- how to locate a specific element in a list c#
- Category
- C#
- Title
- how to flip selection in aseprite
- Category
- C#
- Title
- c# file exist
- Category
- C#
- Title
- how to switch scenes unity
- Category
- C#
- Title
- how to reference a child object unity
- Category
- C#
- Title
- csharp datetime string format
- Category
- C#
- Title
- Unity if object doens't exist
- Category
- C#
- Title
- c# length 2d array
- Category
- C#
- Title
- sort datatable c#
- Category
- C#
- Title
- uwp file open picker
- Category
- C#
- Title
- while loop check condition c#
- Category
- C#
- Title
- c# index in select
- Category
- C#
- Title
- exit game unity
- Category
- C#
- Title
- c# type of generic is string
- Category
- C#
- Title
- c sharp how to read a text file
- Category
- C#
- Title
- how to check if textbox is empty in c#
- Category
- C#
- Title
- how to start grid from where the data starts in c# charts
- Category
- C#
- Title
- unity how to change the text on a button
- Category
- C#
- Title
- count number of enum values C#
- Category
- C#
- Title
- MVC company assignments
- Category
- C#
- Title
- c# tuple access
- Category
- C#
- Title
- how to cast list to observablecollection c#
- Category
- C#
- Title
- value is null to insert in c#
- Category
- C#
- Title
- : ? conditioanl statement c#
- Category
- C#
- Title
- how to go to other forms in C#
- Category
- C#
- Title
- unity how to add a bullet impact force
- Category
- C#
- Title
- epplus excel vb.net
- Category
- C#
- Title
- get random number c#
- Category
- C#
- Title
- c# empty array
- Category
- C#
- Title
- vector3.lerp
- Category
- C#
- Title
- how to declare 2d array in c#
- Category
- C#
- Title
- c sharp list indexer
- Category
- C#
- Title
- generics in c#
- Category
- C#
- Title
- page refresh on button click in c#
- Category
- C#