Created
February 9, 2016 19:32
-
-
Save moon-goon/87caad87b49429f53645 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 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