UILobbyEvent.cs 1021 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using UnityEngine;
  3. namespace ET
  4. {
  5. [UIEvent(UIType.UILobby)]
  6. public class UILobbyEvent: AUIEvent
  7. {
  8. public override async ETTask<UI> OnCreate(UIComponent uiComponent)
  9. {
  10. try
  11. {
  12. ResourcesComponent resourcesComponent = Game.Scene.GetComponent<ResourcesComponent>();
  13. resourcesComponent.LoadBundle(UIType.UILobby.StringToAB());
  14. GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(UIType.UILobby.StringToAB(), UIType.UILobby);
  15. GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject);
  16. UI ui = EntityFactory.Create<UI, string, GameObject>(uiComponent.Domain, UIType.UILobby, gameObject);
  17. ui.AddComponent<UILobbyComponent>();
  18. return ui;
  19. }
  20. catch (Exception e)
  21. {
  22. Log.Error(e);
  23. return null;
  24. }
  25. }
  26. public override void OnRemove(UIComponent uiComponent)
  27. {
  28. uiComponent.Remove(UIType.UILobby);
  29. }
  30. }
  31. }