UIShareComponentSystem.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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(UIShareComponent))]
  10. public static class UIShareComponentSystem
  11. {
  12. [ObjectSystem]
  13. public class UIShareComponentAwakeSystem : AwakeSystem<UIShareComponent>
  14. {
  15. protected override void Awake(UIShareComponent self, params object[] param)
  16. {
  17. ReferenceCollector rc = self.GetParent<UI>().GameObject.GetComponent<ReferenceCollector>();
  18. self.friendShareBtn = rc.Get<GameObject>("friendShareBtn");
  19. self.friendShareBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnFriendShareBtn(); });
  20. self.wechatShareBtn = rc.Get<GameObject>("wechatShareBtn");
  21. self.wechatShareBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnWeixinBtn(); });
  22. self.clickBtn = rc.Get<GameObject>("clickBtn");
  23. self.clickBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnCloseBtn(); });
  24. self.Init();
  25. }
  26. }
  27. private static void Init(this UIShareComponent self)
  28. {
  29. }
  30. public static async void OnFriendShareBtn(this UIShareComponent self)
  31. {
  32. await SoundManager.Instance.PlaySound("clickbtnsound");
  33. }
  34. public static async void OnWeixinBtn(this UIShareComponent self)
  35. {
  36. await SoundManager.Instance.PlaySound("clickbtnsound");
  37. }
  38. public static void OnCloseBtn(this UIShareComponent self)
  39. {
  40. self.OnCloseAsync();
  41. }
  42. public static async void OnCloseAsync(this UIShareComponent self)
  43. {
  44. await UIHelper.Remove(self.ClientScene(),UIType.UIShare);
  45. }
  46. }
  47. }