public UI Create(Scene scene, string type, GameObject parent) { try { Debug.Log("UIRoom_Factory"); ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); AltasComponent altasComponent = Game.Scene.GetComponent <AltasComponent>(); resourcesComponent.LoadBundle($"{ type}.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{type}.unity3d", $"{type}"); GameObject obj = UnityEngine.Object.Instantiate(bundleGameObject); UI ui = ComponentFactory.Create <UI, GameObject>(obj); ui.AddUiComponent <UIRoom_Component>(); //加载扑克图集 resourcesComponent.LoadBundle($"{AltasType.PukeAltas}.unity3d"); GameObject AltasGameObject = (GameObject)resourcesComponent.GetAsset($"{AltasType.PukeAltas}.unity3d", $"{AltasType.PukeAltas}"); GameObject Altas = UnityEngine.Object.Instantiate(AltasGameObject, altasComponent.ParentAltas.transform); altasComponent.AddAltas(AltasType.PukeAltas, Altas); //加载字体图集 resourcesComponent.LoadBundle($"{AltasType.FontAltas}.unity3d"); GameObject FontAltasGameObject = (GameObject)resourcesComponent.GetAsset($"{AltasType.FontAltas}.unity3d", $"{AltasType.FontAltas}"); GameObject FontAltas = UnityEngine.Object.Instantiate(FontAltasGameObject, altasComponent.ParentAltas.transform); altasComponent.AddAltas(AltasType.FontAltas, FontAltas); return(ui); } catch (Exception e) { Debug.LogError(e.Message); return(null); } }
public async Task <UI> LoadBundleAsync(string type) { Type typeComponent = UIType.GetComponentTypeByString(type); ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); await resourcesComponent.LoadBundleAsync($"ui/{type}.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"ui/{type}.unity3d", $"{type}"); GameObject go = UnityEngine.Object.Instantiate(bundleGameObject); go.layer = LayerMask.NameToLayer(LayerNames.UI); UI ui = ComponentFactory.Create <UI, GameObject>(go); ui.AddUiComponent(typeComponent); return(ui); }
public UI Create(Scene scene, string type, GameObject parent) { try { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle(type.StringToAB()); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(type.StringToAB(), type); GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject); gameObject.layer = LayerMask.NameToLayer(LayerNames.UI); UI ui = ComponentFactory.Create <UI, GameObject>(gameObject); ui.AddUiComponent <UILobbyComponent>(); return(ui); } catch (Exception e) { Log.Error(e.ToStr()); return(null); } }
public UI Create(Scene scene, string type, GameObject gameObject) { try { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"{type}.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{type}.unity3d", $"{type}"); GameObject login = UnityEngine.Object.Instantiate(bundleGameObject); login.layer = LayerMask.NameToLayer(LayerNames.UI); UI ui = ComponentFactory.Create <UI, GameObject>(login); ui.AddUiComponent <UILoginComponent>(); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }