Created
July 9, 2017 22:19
-
-
Save srcnalt/d227d9731a30021e610c3aadadb245f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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