Advertisemen
This video will show you guys how to make count down timer in unity 3d in a very simple way.
If you guys like to copy and paste the code used above -
For C# :
using UnityEngine;
using System.Collections;
public class count : MonoBehaviour {
float timeRemaining = 5.0f;
void Update () {
timeRemaining -= Time.deltaTime;
}
void OnGUI(){
if(timeRemaining > 0){
GUI.Label(new Rect(100, 100, 200, 100),
"Time Remaining : "+timeRemaining);
}
else{
GUI.Label(new Rect(100, 100, 200, 100), "Time's Up");
}
}
}
using System.Collections;
public class count : MonoBehaviour {
float timeRemaining = 5.0f;
void Update () {
timeRemaining -= Time.deltaTime;
}
void OnGUI(){
if(timeRemaining > 0){
GUI.Label(new Rect(100, 100, 200, 100),
"Time Remaining : "+timeRemaining);
}
else{
GUI.Label(new Rect(100, 100, 200, 100), "Time's Up");
}
}
}
For Javascript :
#pragma strict
var timeRemaining : float = 5;
function Update () {
timeRemaining -= Time.deltaTime;
}
function OnGUI(){
if(timeRemaining > 0){
GUI.Label(new Rect(100, 100, 200, 100), "Time Remaining : "+timeRemaining);
}
else{
GUI.Label(new Rect(100, 100, 200, 100), "Time's Up");
}
}
var timeRemaining : float = 5;
function Update () {
timeRemaining -= Time.deltaTime;
}
function OnGUI(){
if(timeRemaining > 0){
GUI.Label(new Rect(100, 100, 200, 100), "Time Remaining : "+timeRemaining);
}
else{
GUI.Label(new Rect(100, 100, 200, 100), "Time's Up");
}
}
If this is helpful, please subscribe, like, comment and share with others.
Thank you
Advertisemen
Tidak ada komentar:
Posting Komentar