UILobbyFactory.cs 800 B

1234567891011121314151617181920212223242526272829
  1. using System;
  2. using UnityEngine;
  3. namespace ET
  4. {
  5. public static class UILobbyFactory
  6. {
  7. public static UI Create()
  8. {
  9. try
  10. {
  11. ResourcesComponent resourcesComponent = Game.Scene.GetComponent<ResourcesComponent>();
  12. resourcesComponent.LoadBundle(UIType.UILobby.StringToAB());
  13. GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(UIType.UILobby.StringToAB(), UIType.UILobby);
  14. GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject);
  15. UI ui = EntityFactory.Create<UI, string, GameObject>(Game.Scene, UIType.UILobby, gameObject);
  16. ui.AddComponent<UILobbyComponent>();
  17. return ui;
  18. }
  19. catch (Exception e)
  20. {
  21. Log.Error(e);
  22. return null;
  23. }
  24. }
  25. }
  26. }