Skip to content

Instantly share code, notes, and snippets.

@moon-goon
Created February 9, 2016 19:32
Show Gist options
  • Select an option

  • Save moon-goon/87caad87b49429f53645 to your computer and use it in GitHub Desktop.

Select an option

Save moon-goon/87caad87b49429f53645 to your computer and use it in GitHub Desktop.
using UnityEngine;
using UnityEngine.UI;
public class NameTag : MonoBehaviour {
public string displayName;
public Text targetName;
private bool isDisplaying = false;
void Start() {
//Debug.Log(gameObject.GetComponentInChildren<Text>());
targetName = gameObject.GetComponentInChildren<Text>();
targetName.color = Color.clear;
}
void Update() {
if (isDisplaying) {
targetName.text = displayName;
targetName.color = Color.Lerp(targetName.color, Color.green, 10 * Time.deltaTime);
}
else {
targetName.text = displayName;
targetName.color = Color.Lerp(targetName.color, Color.clear, 10 * Time.deltaTime);
}
}
void OnMouseOver() {
isDisplaying = true;
}
void OnMouseExit() {
isDisplaying = false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment