title: How to change UI Text Color
body: <p>My script works on on 3D GameObject but not on a <code>Text</code> component. How can I make it work on a Text? I would appreciate for you help.</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class Colors : MonoBehaviour
  
  {
  public float timer = 0.0f;
  Renderer rd;
  
  void Start()
  {
      rd = gameObject.GetComponent&lt;Renderer&gt;();
  }
  
  
  void Update()
  {
      timer += Time.deltaTime;
      if (timer &gt;= 2.0f)//change the float value here to change how long it takes to switch.
      {
          // pick a random color
          Color newColor = new Color(Random.value, Random.value, Random.value, 1.0f);
          // apply it on current object's material
          rd.material.color = newColor;
  
          timer = 0;
      }
  }
  </code></pre>
  
  <p>}</p>