Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class UIAnimController : MonoBehaviour {
  7.  
  8.     public float animationTime;
  9.     public GameObject ui;
  10.     // Use this for initialization
  11.     void Start () {
  12.         ui.SetActive (false);
  13.        
  14.     }
  15.    
  16.     // Update is called once per frame
  17.     void Update () {
  18.        
  19.     }
  20.  
  21.  
  22.     public void StartAnimation(string _message)
  23.     {
  24.             ui.SetActive (true);
  25.             ui.GetComponentInChildren<Text> ().text = _message;
  26.             ui.GetComponent<Animator> ().SetBool ("startAnim", ui.activeSelf);
  27.             StartCoroutine("EndAnimation");
  28.        
  29.     }
  30.  
  31.  
  32.     private IEnumerator EndAnimation(){
  33.  
  34.         yield return new WaitForSeconds(animationTime);
  35.        
  36.             ui.GetComponent<Animator> ().SetBool ("startAnim", false);
  37.             ui.SetActive (false);
  38.        
  39.  
  40.  
  41.     }
  42.        
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement