UIMessageComponentSystem.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading.Tasks;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. using static System.Net.Mime.MediaTypeNames;
  7. namespace ET.Client
  8. {
  9. [FriendOf(typeof(UIMessageComponent))]
  10. public static class UIMessageComponentSystem
  11. {
  12. [ObjectSystem]
  13. public class UIMessageComponentAwakeSystem : AwakeSystem<UIMessageComponent>
  14. {
  15. protected override void Awake(UIMessageComponent self, params object[] param)
  16. {
  17. ReferenceCollector rc = self.GetParent<UI>().GameObject.GetComponent<ReferenceCollector>();
  18. self.sureBtn = rc.Get<GameObject>("sureBtn");
  19. self.sureBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnCloseBtn(); });
  20. self.Init();
  21. }
  22. }
  23. private static void Init(this UIMessageComponent self)
  24. {
  25. }
  26. public static async void OnCloseBtn(this UIMessageComponent self)
  27. {
  28. await SoundManager.Instance.PlaySound("clickbtnsound");
  29. self.OnCloseAsync();
  30. }
  31. public static async void OnCloseAsync(this UIMessageComponent self)
  32. {
  33. await UIHelper.Remove(self.ClientScene(),UIType.UIMessage);
  34. }
  35. }
  36. }