GenericUINotification.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using UnityEngine;
  2. using System.Collections;
  3. public class GenericUINotification : MonoBehaviour
  4. {
  5. ScreenBase screen;
  6. UILabel label;
  7. public GameObject SectionDialogButton;
  8. public GameObject SectionErrorButton;
  9. void Awake()
  10. {
  11. label = GetComponentInChildren<UILabel>();
  12. screen = GetComponent<ScreenBase>();
  13. Debug.Log("AddListener");
  14. NotificationCenter.AddListener(OnShowGenericNotification, NotificationType.ShowGenericNotification);
  15. NotificationCenter.AddListener(OnShowGenericNotification, NotificationType.ShowDialogNotification);
  16. NotificationCenter.AddListener(OnShowGenericNotification, NotificationType.ShowDialogNotificationError);
  17. }
  18. void OnDestroy()
  19. {
  20. NotificationCenter.RemoveListener(OnShowGenericNotification, NotificationType.ShowGenericNotification);
  21. NotificationCenter.RemoveListener(OnShowGenericNotification, NotificationType.ShowDialogNotification);
  22. NotificationCenter.RemoveListener(OnShowGenericNotification, NotificationType.ShowDialogNotificationError);
  23. }
  24. public void OnShowGenericNotification(Notification note)
  25. {
  26. //Debug.Log("OnShowGenericNotification");
  27. label.text = (string)note.data;
  28. screen.Show();
  29. screen.Invoke("Hide", 3);
  30. }
  31. public void ShowDialogNotification(Notification note)
  32. {
  33. //Debug.Log("OnShowGenericNotification");
  34. label.text = (string)note.data;
  35. screen.Show();
  36. SectionDialogButton.SetActive(true);
  37. SectionErrorButton.SetActive(false);
  38. }
  39. public void CloseDialogNotification()
  40. {
  41. SectionDialogButton.SetActive(false);
  42. screen.Hide();
  43. }
  44. public void CloseAccessDialogNotificationWithYes()
  45. {
  46. SectionDialogButton.SetActive(false);
  47. SectionErrorButton.SetActive(false);
  48. screen.Hide();
  49. }
  50. public void ShowDialogNotificationError(Notification note)
  51. {
  52. label.text = (string)note.data;
  53. screen.Show();
  54. SectionDialogButton.SetActive(false);
  55. SectionErrorButton.SetActive(true);
  56. }
  57. }