TextNotification.cs 722 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. public class TextNotification : MonoBehaviour
  4. {
  5. [SerializeField]
  6. private Animator anim;
  7. [SerializeField]
  8. private Text message;
  9. [SerializeField]
  10. private Button closeBannerButton;
  11. [SerializeField]
  12. private float timeToHide = 4;
  13. public void Setup(string msg)
  14. {
  15. message.text = msg;
  16. }
  17. private void Update()
  18. {
  19. timeToHide -= Time.deltaTime;
  20. if(timeToHide <= 0)
  21. CloseNotification();
  22. }
  23. public void CloseNotification()
  24. {
  25. anim.SetBool("Hide", true);
  26. closeBannerButton.interactable = false;
  27. }
  28. public void Destroy()
  29. {
  30. Destroy(gameObject);
  31. }
  32. }