Skip to content

Instantly share code, notes, and snippets.

@srcnalt
Created July 9, 2017 22:19
Show Gist options
  • Save srcnalt/d227d9731a30021e610c3aadadb245f4 to your computer and use it in GitHub Desktop.
Save srcnalt/d227d9731a30021e610c3aadadb245f4 to your computer and use it in GitHub Desktop.
using UnityEngine;
using UnityEngine.UI;
public class TextColor : MonoBehaviour {
public Color from = new Color(255, 255, 0);
public Color to = new Color(0, 255, 0);
public float switchDuration = 1;
private Color change;
private Text myText;
private void Start()
{
myText = GetComponent<Text>();
myText.color = from;
}
void Update () {
Color change = Color.Lerp(from, to, Mathf.PingPong(Time.time / switchDuration, 1));
myText.color = change;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment