Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

[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.