thieumao

Unity - Dem nguoc thoi gian

Sep 2nd, 2015
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.41 KB | None | 0 0
  1. // file: CountdownTimer.cs
  2. using UnityEngine;
  3. using System.Collections;
  4.  
  5. public class CountdownTimer : MonoBehaviour {
  6.     private float secondsLeft = 10f;
  7.    
  8.     private void OnGUI(){
  9.         if( secondsLeft > 0)
  10.             GUILayout.Label("Countdown seconds remaining = " + (int)secondsLeft     );
  11.         else
  12.             GUILayout.Label("Countdown has finished");
  13.        
  14.     }
  15.    
  16.     private void Update(){
  17.         secondsLeft -= Time.deltaTime;
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment