Count Down Timer in Unity 3d [ Video ]

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(100100200100), 

                         "Time Remaining : "+timeRemaining);
        }
        else{
            GUI.Label(new Rect(100100200100), "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(100100200100), "Time Remaining : "+timeRemaining);
    }
    else{
        GUI.Label(new Rect(100100200100), "Time's Up");
    }
}

If this is helpful, please subscribe, like, comment and share with others.

Thank you

Advertisemen

Disclaimer: Gambar, artikel ataupun video yang ada di web ini terkadang berasal dari berbagai sumber media lain. Hak Cipta sepenuhnya dipegang oleh sumber tersebut. Jika ada masalah terkait hal ini, Anda dapat menghubungi kami disini.

Tidak ada komentar:

Posting Komentar

© Copyright 2017 Tutorial Unity 3D