Advertisement
Guest User

Untitled

a guest
Dec 7th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement