Search Unity

Display game time on a GameObject

Discussion in 'Editor & General Support' started by herbie, Sep 7, 2013.

  1. herbie

    herbie

    Joined:
    Feb 11, 2012
    Posts:
    237
    Hi,

    You can display the game time with this script:
    Code (csharp):
    1. private var min: int;
    2. private var sec: int;
    3. private var timecount: float;
    4. private var starttime: float;
    5. public var gametime: GUIText;
    6.      
    7. function Start ()
    8. {
    9.     starttime = Time.time;
    10. }
    11.      
    12. function Update ()
    13. {
    14.     timecount = Time.time - starttime;
    15.     min = (timecount/60f);
    16.     sec = (timecount % 60f);
    17.     gametime.text = String.Format("{0:00}:{1:00}",min,sec);
    18. }
    But it's OnGUI.

    Is it possible to display the game time on a GameObject like a plane or a cube?
    (somewhere in my game there is some kind of tv screen that must be display the game time)
     
  2. herbie

    herbie

    Joined:
    Feb 11, 2012
    Posts:
    237
    I found the answer already.
    You can do that with TextMesh.