Advertisement
Guest User

Notice.cs

a guest
Jul 31st, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4.  
  5. public class Notice : Text {
  6.     float showTime;
  7.     float lerpSpeed;   
  8.     bool isHide;
  9.    
  10.     void Update() {
  11.         if(isHide) {
  12.             color = Color.Lerp(color, new Color(color.r, color.g, color.b, 0), lerpSpeed * Time.deltaTime);
  13.         }
  14.     }
  15.    
  16.     public void Output(string noticeText, Color noticeColor, float showTime, float lerpSpeed) {
  17.         text = noticeText;
  18.         color = noticeColor;
  19.         this.showTime = showTime;
  20.         this.lerpSpeed = lerpSpeed;
  21.         StartCoroutine(Hide());
  22.     }
  23.    
  24.     IEnumerator Hide() {
  25.         isHide = false;
  26.         yield return new WaitForSeconds(showTime);
  27.         isHide = true;
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement