Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Dec 7th, 2018 56 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class ShowText : MonoBehaviour {
  7.  
  8.     // Use this for initialization
  9.  
  10.     public string myString;
  11.     public Text myText;
  12.     public float fadeTime;
  13.     public bool displayInfo;
  14.  
  15.  
  16.     void Start()
  17.     {
  18.  
  19.         myText = GameObject.Find("Text").GetComponent<Text>();
  20.         myText.color = Color.clear;
  21.  
  22.     }
  23.  
  24.     void OnMouseOver()
  25.     {
  26.         displayInfo = true;
  27.     }
  28.  
  29.     void OnMouseExit()
  30.     {
  31.         displayInfo = false;
  32.     }
  33.  
  34.     // Update is called once per frame
  35.     void Update () {
  36.  
  37.         FadeText();
  38.     }
  39.  
  40.     void FadeText()
  41.  
  42.     {
  43.  
  44.  
  45.         if (displayInfo)
  46.         {
  47.  
  48.             myText.text = myString;
  49.             myText.color = Color.Lerp(myText.color, Color.white, fadeTime * Time.deltaTime);
  50.         }
  51.  
  52.         else
  53.         {
  54.  
  55.             myText.color = Color.Lerp(myText.color, Color.clear, fadeTime * Time.deltaTime);
  56.         }
  57.  
  58.  
  59.  
  60.  
  61.     }
  62.  
  63.  
  64.  
  65.  
  66. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top