UIInvateComponentSystem.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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(UIInvateComponent))]
  10. public static class UIInvateComponentSystem
  11. {
  12. [ObjectSystem]
  13. public class UIInvateComponentAwakeSystem : AwakeSystem<UIInvateComponent>
  14. {
  15. protected override void Awake(UIInvateComponent self, params object[] param)
  16. {
  17. ReferenceCollector rc = self.GetParent<UI>().GameObject.GetComponent<ReferenceCollector>();
  18. self.InvateObj = rc.Get<GameObject>("InvateObj");
  19. self.UnInvateObj = rc.Get<GameObject>("UnInvateObj");
  20. self.yourInvate = rc.Get<GameObject>("yourInvate");
  21. self.invateInput = rc.Get<GameObject>("invateInput");
  22. self.sureBtn = rc.Get<GameObject>("sureBtn");
  23. self.sureBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnSureBtn(); });
  24. self.Init();
  25. }
  26. }
  27. private static void Init(this UIInvateComponent self)
  28. {
  29. self.UnInvateObj.SetActive(false);
  30. self.InvateObj.SetActive(true);
  31. }
  32. public static async void OnSureBtn(this UIInvateComponent self)
  33. {
  34. await SoundManager.Instance.PlaySound("clickbtnsound");
  35. self.OnCloseAsync();
  36. }
  37. public static async void OnCloseAsync(this UIInvateComponent self)
  38. {
  39. await UIHelper.Remove(self.ClientScene(),UIType.UIInvate);
  40. }
  41. }
  42. }