UIMainEvent.cs 1019 B

12345678910111213141516171819202122232425
  1. using System;
  2. using UnityEngine;
  3. namespace ET.Client
  4. {
  5. [UIEvent(UIType.UIMain)]
  6. public class UIMainEvent : AUIEvent
  7. {
  8. public override async ETTask<UI> OnCreate(UIComponent uiComponent, UILayer uiLayer)
  9. {
  10. await ETTask.CompletedTask;
  11. await uiComponent.DomainScene().GetComponent<ResourcesLoaderComponent>().LoadAsync(UIType.UIMain.StringToAB());
  12. GameObject bundleGameObject = (GameObject) ResourcesComponent.Instance.GetAsset(UIType.UIMain.StringToAB(), UIType.UIMain);
  13. GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject, UIEventComponent.Instance.GetLayer((int)uiLayer));
  14. UI ui = uiComponent.AddChild<UI, string, GameObject>(UIType.UIMain, gameObject);
  15. ui.AddComponent<UIMainComponent>();
  16. return ui;
  17. }
  18. public override void OnRemove(UIComponent uiComponent)
  19. {
  20. ResourcesComponent.Instance.UnloadBundle(UIType.UIMain.StringToAB());
  21. }
  22. }
  23. }