Search Unity

[Solved] Question - Countdown Time C#

Discussion in 'Scripting' started by kholyphoenix1, Nov 18, 2015.

  1. kholyphoenix1

    kholyphoenix1

    Joined:
    Apr 17, 2015
    Posts:
    57
    Hello,

    I was watching one video on youtube of how to create a weather system. "Countdown timer".
    When I put this script in character counter is not visible in the game.

    Code (CSharp):
    1. // Converted from UnityScript to C# at http://www.M2H.nl/files/js_to_c.php - by Mike Hergaarden
    2. // Do test the code! You usually need to change a few small bits.
    3.  
    4. using UnityEngine;
    5. using System.Collections;
    6.  
    7. public class Timer : MonoBehaviour {
    8.  
    9.     // Variáveis
    10.     float timer = 10.0f;
    11.  
    12.     // Iniciar
    13.     void  Update (){
    14.  
    15.         timer -= Time.deltaTime;
    16.  
    17.         // The End
    18.         /*
    19.         if(timer <= 0) {
    20.             timer = 0;
    21.         }
    22.         */
    23.  
    24.     }
    25.  
    26.     void  onGUI (){
    27.         GUI.Box(new Rect(10, 10, 150, 100), "" + "Time: " + timer.ToString("0"));
    28.     }
    29. }
     
  2. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    onGUI() should be OnGUI()
     
  3. kholyphoenix1

    kholyphoenix1

    Joined:
    Apr 17, 2015
    Posts:
    57
    Solved!!
    *-*

    Thanks a lot!!
     
    larku likes this.