countdown script in 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# try catch error
- Category
- C#
- Title
- asign only common fields in c# object
- Category
- C#
- Title
- c# uppercase string
- Category
- C#
- Title
- c# array isn't working
- Category
- C#
- Title
- unity string format time
- Category
- C#
- Title
- c# creating exceptions
- Category
- C#
- Title
- how to clear console in c#
- Category
- C#
- Title
- null coalesce ternary c#
- Category
- C#
- Title
- how to sort string array alphabetically in c#
- Category
- C#
- Title
- image filter
- Category
- C#
- Title
- : ? conditioanl statement c#
- Category
- C#
- Title
- c# read excel file
- Category
- C#
- Title
- c# arraylist contains
- Category
- C#
- Title
- if and c#
- Category
- C#
- Title
- unity vector3 smoothdamp not reaching target
- Category
- C#
- Title
- eager loading c#
- Category
- C#
- Title
- add mime type for woff in web.config
- Category
- C#
- Title
- xamarin forms alarm
- Category
- C#
- Title
- write last line txt file c#
- Category
- C#
- Title
- c sharp add item to dictionary
- Category
- C#
- Title
- loop gridcontrol devexpress c#
- Category
- C#
- Title
- c# get full URL of page
- Category
- C#
- Title
- validating file upload asp.net core mvc
- Category
- C#
- Title
- how to find object by ag unity
- Category
- C#
- Title
- Net.ServicePointManager.SecurityProtocol .net framework 4
- Category
- C#
- Title
- microsoft input tool need .net framework
- Category
- C#
- Title
- dynamic convert type c#
- Category
- C#
- Title
- sqlite connection c#
- Category
- C#
- Title
- configure 1 to 1 relation ef
- Category
- C#
- Title
- The type or namespace name 'Scrollbar' could not be found
- Category
- C#
- Title
- convert comma separated string to array c#
- Category
- C#
- Title
- c# using get set methods
- Category
- C#
- Title
- how to cjeck if a string has a word c#
- Category
- C#
- Title
- c# string to lowercase
- Category
- C#
- Title
- unity custom editor save changes
- Category
- C#
- Title
- how to add object in dictionary in c#
- Category
- C#
- Title
- read configuration workerservice
- Category
- C#
- Title
- C# move form without border
- Category
- C#
- Title
- c# list.foreach
- Category
- C#
- Title
- how to make a for loop in c#
- Category
- C#
- Title
- c# create a text file
- Category
- C#
- Title
- hwo to make an array in C#
- Category
- C#
- Title
- unity 2d joystick controls
- Category
- C#
- Title
- how to stop a form c#
- Category
- C#
- Title
- c# list string return concatenate
- Category
- C#
- Title
- unity list length
- Category
- C#
- Title
- c# properties
- Category
- C#
- Title
- how to track a branch on github
- Category
- C#
- Title
- countdown script unity
- Category
- C#
- Title
- c# one line set
- Category
- C#
- Title
- bitmap to byte array c#
- Category
- C#
- Title
- c# long to int
- Category
- C#
- Title
- how to store some variables on the device in unity
- Category
- C#
- Title
- c# xml file builder
- Category
- C#
- Title
- date time heutiges datum
- Category
- C#
- Title
- move towards target unity
- Category
- C#
- Title
- c# split a string and return list
- Category
- C#
- Title
- c# read a webpage data
- Category
- C#
- Title
- C# type cast float to string
- Category
- C#
- Title
- c# read file stream
- Category
- C#
- Title
- nullreferenceexception c#
- Category
- C#
- Title
- center an image horizontally and vertically
- Category
- C#
- Title
- how to create a variable in C#
- Category
- C#
- Title
- leantween id
- Category
- C#
- Title
- call Textboxfor in cs
- Category
- C#
- Title
- how to stop window from terminating c# visual studio
- Category
- C#
- Title
- native-googlesignin configuration is null!?
- Category
- C#
- Title
- Globalization and localization in ASP.NET Core
- Category
- C#
- Title
- verifyusertokenasync password reset token
- Category
- C#
- Title
- how to reduce garbage collection c#
- Category
- C#
- Title
- c# check internet connection easy
- Category
- C#
- Title
- c# length of array
- Category
- C#
- Title
- replace double backslash with single backslash c#
- Category
- C#
- Title
- unity movetowards 2d
- Category
- C#
- Title
- call a function c#
- Category
- C#
- Title
- c# how to check if two lists have same values
- Category
- C#
- Title
- how to trim path in C#
- Category
- C#
- Title
- C# get all child classes of a class
- Category
- C#
- Title
- c# exit for
- Category
- C#
- Title
- c# convert column name to number
- Category
- C#
- Title
- linq c# object except two lists
- Category
- C#
- Title
- jump script unity 2d
- Category
- C#
- Title
- how to close a windows form application in c#
- Category
- C#
- Title
- Request.Form
- Category
- C#
- Title
- delay in unity
- Category
- C#
- Title
- two players one phone unity gamne
- Category
- C#
- Title
- count the number of notes in a given amount c#
- Category
- C#
- Title
- how to set a gizmo color unity
- Category
- C#
- Title
- unity 2d detect click on sprite
- Category
- C#
- Title
- c# silent execute exe
- Category
- C#
- Title
- c# stringbuilder
- Category
- C#
- Title
- using mediamanager how to play mp3 files
- Category
- C#
- Title
- button color uwp c#
- Category
- C#
- Title
- windows forms iterate through all controls
- Category
- C#
- Title
- c# mailmessage set sender name
- Category
- C#
- Title
- iframe set html content c#
- Category
- C#
- Title
- c# ienumerable to list
- Category
- C#
- Title
- c# sql duplicate key exception
- Category
- C#
- Title
- c# creating a data recovery software
- Category
- C#
- Title
- how to clear console through script unity
- Category
- C#