UIMainEvent.cs 979 B

123456789101112131415161718192021222324
  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 uiComponent.DomainScene().GetComponent<ResourcesLoaderComponent>().LoadAsync(UIType.UIMain.StringToAB());
  11. GameObject bundleGameObject = (GameObject) ResourcesComponent.Instance.GetAsset(UIType.UIMain.StringToAB(), UIType.UIMain);
  12. GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject, UIEventComponent.Instance.GetLayer((int)uiLayer));
  13. UI ui = uiComponent.AddChild<UI, string, GameObject>(UIType.UIMain, gameObject);
  14. ui.AddComponent<UIMainComponent>();
  15. return ui;
  16. }
  17. public override void OnRemove(UIComponent uiComponent)
  18. {
  19. ResourcesComponent.Instance.UnloadBundle(UIType.UIMain.StringToAB());
  20. }
  21. }
  22. }