Search Unity

change GUIText in script how?

Discussion in 'Scripting' started by MG, Jun 30, 2015.

  1. MG

    MG

    Joined:
    Nov 10, 2012
    Posts:
    190
    I'm using a Canvas and a text component (See attached file)

    How do i though script make it change to like. Time.deltaTime?
     

    Attached Files:

  2. PGJ

    PGJ

    Joined:
    Jan 21, 2014
    Posts:
    899
    You can do something like this, place this on the text component:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using System.Collections;
    4.  
    5. public class TextTest : MonoBehaviour {
    6.     void Update () {
    7.         GetComponent<Text>().text = Time.deltaTime.ToString();
    8.     }
    9. }
    10.