GenericUINotification.cs 693 B

123456789101112131415161718192021222324252627282930
  1. using UnityEngine;
  2. using System.Collections;
  3. public class GenericUINotification : MonoBehaviour
  4. {
  5. ScreenBase screen;
  6. UILabel label;
  7. void Awake()
  8. {
  9. label = GetComponentInChildren<UILabel>();
  10. screen = GetComponent<ScreenBase>();
  11. //Debug.Log("AddListener");
  12. NotificationCenter.AddListener(OnShowGenericNotification, NotificationType.ShowGenericNotification);
  13. }
  14. void OnDestroy()
  15. {
  16. NotificationCenter.RemoveListener(OnShowGenericNotification, NotificationType.ShowGenericNotification);
  17. }
  18. public void OnShowGenericNotification(Notification note)
  19. {
  20. Debug.Log("OnShowGenericNotification");
  21. label.text = (string)note.data;
  22. screen.Show();
  23. screen.Invoke("Hide", 3);
  24. }
  25. }