UILoadingEvent.cs 869 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using UnityEngine;
  3. namespace ET
  4. {
  5. [UIEvent(UIType.UILoading)]
  6. public class UILoadingEvent: AUIEvent
  7. {
  8. public override async ETTask<UI> OnCreate(UIComponent uiComponent)
  9. {
  10. try
  11. {
  12. GameObject bundleGameObject = ((GameObject)Resources.Load("KV")).Get<GameObject>(UIType.UILoading);
  13. GameObject go = UnityEngine.Object.Instantiate(bundleGameObject);
  14. go.layer = LayerMask.NameToLayer(LayerNames.UI);
  15. UI ui = EntityFactory.Create<UI, string, GameObject>(uiComponent.Domain, UIType.UILoading, go);
  16. ui.AddComponent<UILoadingComponent>();
  17. return ui;
  18. }
  19. catch (Exception e)
  20. {
  21. Log.Error(e);
  22. return null;
  23. }
  24. }
  25. public override void OnRemove(UIComponent uiComponent)
  26. {
  27. uiComponent.Remove(UIType.UILoading);
  28. }
  29. }
  30. }