Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class ShowText : MonoBehaviour {
- // Use this for initialization
- public string myString;
- public Text myText;
- public float fadeTime;
- public bool displayInfo;
- void Start()
- {
- myText = GameObject.Find("Text").GetComponent<Text>();
- myText.color = Color.clear;
- }
- void OnMouseOver()
- {
- displayInfo = true;
- }
- void OnMouseExit()
- {
- displayInfo = false;
- }
- // Update is called once per frame
- void Update () {
- FadeText();
- }
- void FadeText()
- {
- if (displayInfo)
- {
- myText.text = myString;
- myText.color = Color.Lerp(myText.color, Color.white, fadeTime * Time.deltaTime);
- }
- else
- {
- myText.color = Color.Lerp(myText.color, Color.clear, fadeTime * Time.deltaTime);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement