public static async ETVoid EnterMapAsync(string sceneName) { try { // 加载Unit资源 ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); await resourcesComponent.LoadBundleAsync($"unit.unity3d"); // 加载场景资源 await ETModel.Game.Scene.GetComponent <ResourcesComponent>().LoadBundleAsync("map.unity3d"); // 切换到map场景 using (SceneChangeComponent sceneChangeComponent = ETModel.Game.Scene.AddComponent <SceneChangeComponent>()) { await sceneChangeComponent.ChangeSceneAsync(sceneName); } G2C_EnterMap g2CEnterMap = await ETModel.SessionComponent.Instance.Session.Call(new C2G_EnterMap()) as G2C_EnterMap; PlayerComponent.Instance.MyPlayer.UnitId = g2CEnterMap.UnitId; Game.Scene.AddComponent <OperaComponent>(); Game.EventSystem.Run(EventIdType.EnterMapFinish); } catch (Exception e) { Log.Error(e); } }
public static async ETTask DownloadBundle() { if (Define.IsAsync) { try { Game.EventSystem.Run(EventIdType.LoadingBegin); Game.Scene.AddComponent <BundleDownloaderComponent>(); await GameUpdateMgr.Ins.UpdateGame(); Game.Scene.GetComponent <ResourcesComponent>().LoadOneBundle("StreamingAssets"); ResourcesComponent.SetAssetBundleManifestObject((AssetBundleManifest)Game.Scene.GetComponent <ResourcesComponent>().BundleNameGetAsset("StreamingAssets", "AssetBundleManifest")); Game.EventSystem.Run(EventIdType.LoadingFinish); } catch (Exception e) { UILoadingComponent.Ins.ShowHint("网络无法连接,请检查您的网络", (bol) => { Application.Quit(); Log.Error("退出了游戏"); }, PopHintOptionType.Single, "确 定"); Log.Error(e); } } else { #if UNITY_EDITOR ResourcesComponent.RecordAssbundlsName(AssetDatabase.GetAllAssetBundleNames()); #endif } }
public UI Create(Scene scene, string type, GameObject parent) { try { //加载AB包 ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"{type}.unity3d"); //加载大厅界面预设并生成实例 GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{type}.unity3d", $"{type}"); GameObject mainLobby = UnityEngine.Object.Instantiate(bundleGameObject); //设置UI层级,只有UI摄像机可以渲染 mainLobby.layer = LayerMask.NameToLayer(LayerNames.UI); UI ui = ComponentFactory.Create <UI, GameObject>(mainLobby); ui.AddComponent <StartLobbyComponent>(); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }
protected override void Run(Session session, Actor_CreateUnits message) { // 加载Unit资源 ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"Unit.unity3d"); UnitComponent unitComponent = ETModel.Game.Scene.GetComponent <UnitComponent>(); foreach (UnitInfo unitInfo in message.Units) { if (unitComponent.Get(unitInfo.UnitId) != null) { continue; } Unit unit = UnitFactory.Create(unitInfo.UnitId); unit.Position = new Vector3(unitInfo.X / 1000f, 0, unitInfo.Z / 1000f); unit.IntPos = new VInt3(unitInfo.X, 0, unitInfo.Z); if (PlayerComponent.Instance.MyPlayer.UnitId == unit.Id) { ETModel.Game.Scene.GetComponent <CameraComponent>().Unit = unit; } } Game.Scene.AddComponent <OperaComponent>(); }
/// <summary> /// 初始化对象池容器 /// </summary> /// <param name="poolName"></param> /// <param name="abName"></param> /// <param name="assetName"></param> /// <param name="capacity"></param> public ObjPool(string poolName, string abName, string assetName, int capacity) { _poolName = poolName; _abName = abName; _assetName = assetName; poolQuque = new Queue <GameObject>(capacity); PoolParent = GameObject.Find("ObjectPool").transform; ResourcesComponent res = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); res.LoadBundle(abName.StringToAB()); assetObject = (GameObject)res.GetAsset(abName.StringToAB(), assetName); for (int i = 0; i < capacity; i++) { GameObject objClone = (GameObject)UnityEngine.Object.Instantiate(assetObject); objClone.SetActive(false); objClone.transform.SetParent(PoolParent); poolQuque.Enqueue(objClone); } }
public static UnityEngine.Object GetResoure(this ResourcesComponent resourcesComponent, string uiType, string resName) { try { if (cacheResRecord.ContainsKey(resName)) { return(cacheResRecord[resName]); } abBundleNames[1] = uiType; foreach (var bundleName in abBundleNames) { GameObject ReferenceCollectorGo = (GameObject)resourcesComponent.AwayPrefixGetAsset($"{bundleName}.unity3d", "ReferenceCollector"); UnityEngine.Object bundleGameObject = ReferenceCollectorGo.Get <UnityEngine.Object>(resName); if (bundleGameObject != null) { cacheResRecord.Add(resName, bundleGameObject); return(bundleGameObject); } } } catch (Exception e) { Log.Error(e); throw; } return(null); }
public async void Awake() { Instance = this; //初始化加载一次 ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); await resourcesComponent.LoadBundleAsync("sound.unity3d"); _musicMute = PlayerPrefs.GetInt("MusicMute", 0) == 1; _soundMute = PlayerPrefs.GetInt("SoundMute", 0) == 1; _soundVolume = PlayerPrefs.GetFloat("SoundVolume", 0.5f); _sfxVolume = PlayerPrefs.GetFloat("SFXVolume", 1); root = new GameObject("SoundDatas").transform; GameObject.DontDestroyOnLoad(root.gameObject); if (_soundVolume > 0.5f) { _soundVolume = 0.5f; } //组件初始化完成后,直接调用播放背景音乐的方法 this.PlayMusic("SoundBgHall", 0, _soundVolume, true); //注册按钮默认点击音效 ButtonClickSound.RegisterPlayButtonSound(); }
public static Unit Create(long id) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit"); GameObject prefab = bundleGameObject.Get <GameObject>("Skeleton"); UnitComponent unitComponent = Game.Scene.GetComponent <UnitComponent>(); GameObject go = UnityEngine.Object.Instantiate(prefab); Unit unit = ComponentFactory.CreateWithId <Unit, GameObject>(id, go); unit.AddComponent <AnimatorComponent>(); SyncType type = Game.Scene.GetComponent <NetSyncComponent>().type; if (type == SyncType.Frame) { unit.AddComponent <FrameMoveComponent>(); } else if (type == SyncType.State) { unit.AddComponent <MoveComponent>(); unit.AddComponent <TurnComponent>(); unit.AddComponent <UnitPathComponent>(); } unitComponent.Add(unit); return(unit); }
public Task <AssetBundle> LoadAsync(string path, Action <float> updateProgress = null) { this.updateProgress = updateProgress; this.tcs = new TaskCompletionSource <AssetBundle>(); AbPath = path; ResourcesComponent resComponent = Game.Scene.GetComponent <ResourcesComponent>(); if (resComponent.DicABRequest.ContainsKey(path)) { if (resComponent.DicABRequest[path] == null) { resComponent.DicABRequest.Remove(path); } else if (resComponent.DicABRequest[path].assetBundle == null) { resComponent.DicABRequest.Remove(path); } else { this.request = resComponent.DicABRequest[path]; return(this.tcs.Task); } } this.request = AssetBundle.LoadFromFileAsync(path); if (!resComponent.DicABRequest.ContainsKey(AbPath)) { resComponent.DicABRequest.Add(AbPath, this.request); } return(this.tcs.Task); }
public static Bullet Create(Tank tank) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); Game.Scene.GetComponent <ResourcesComponent>().LoadBundle($"Unit.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit"); Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle($"Unit.unity3d"); GameObject prefab = bundleGameObject.Get <GameObject>("Bullet"); BulletComponent bulletComponent = tank.GetComponent <BulletComponent>(); Bullet bullet = ComponentFactory.CreateWithId <Bullet, Tank>(IdGenerater.GenerateId(), tank); bullet.GameObject = resourcesComponent.NewObj(PrefabType.Bullet, prefab); GameObject parent = tank.GameObject.FindChildObjectByPath("bullets"); bullet.GameObject.transform.SetParent(parent.transform, false); bulletComponent.Add(bullet); BulletCollision bulletCollision = bullet.GameObject.AddComponent <BulletCollision>(); // 子弹添加飞行 bulletCollision.BulletFly = bullet.AddComponent <BulletFlyComponent>(); return(bullet); }
/// <summary> /// 准备英雄资源 /// </summary> /// <param name="heroType"></param> private static void PrepareHeroRes(string heroType) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); GameObject bundleGameObject = resourcesComponent.LoadAsset <GameObject>(ABPathUtilities.GetUnitPath("Unit")); GameObject prefab = bundleGameObject.GetTargetObjectFromRC <GameObject>(heroType); Game.Scene.GetComponent <GameObjectPool>().Add(heroType, prefab); }
Sprite CreateSprite(string abName, string imgName) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); Texture2D tex = (Texture2D)resourcesComponent.GetAsset(abName.StringToAB(), imgName); return(Sprite.Create(tex, new Rect(0.0f, 0.0f, tex.width, tex.height), new Vector2(0.5f, 0.5f), 100.0f)); }
private void LoadGraph() { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle("graph.unity3d"); GameObject graphRef = resourcesComponent.GetAsset("graph.unity3d", "Graph") as GameObject; TextAsset graph = graphRef.Get <TextAsset>("Graph"); this.AStarConfig.graphs = DeserializeHelper.Load(graph.bytes); }
public static BehaviorTree CreateEnemy() { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("enemy.unity3d", "Enemy"); GameObject prefab = bundleGameObject.Get <GameObject>("Enemy1"); GameObject go = UnityEngine.Object.Instantiate(prefab); BehaviorTree behaviorTree = go.GetComponent <BehaviorTree>(); return(behaviorTree); }
//加载声音 private async Task <SoundData> LoadSound(string soundName) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); if (!abSounds.ContainsKey(soundName) || abSounds[soundName] == null) { //await resourcesComponent.LoadBundleAsync("sound.unity3d"); abSounds.Add(soundName, GameObject.Instantiate((GameObject)resourcesComponent.GetAsset("sound.unity3d", soundName)).GetComponent <SoundData>()); //resourcesComponent.UnloadBundle("sound.unity3d"); } return(abSounds[soundName]); }
//省略 前缀 卸载AB包 public static void AwayPrefixUnloadBundle(this ResourcesComponent resourcesComponent, string assetBundleName) { assetBundleName = assetBundleName.ToLower(); if (ResourcesComponent.bundlesNameDictionary.ContainsKey(assetBundleName)) { resourcesComponent.UnloadBundle(ResourcesComponent.bundlesNameDictionary[assetBundleName] + "/" + assetBundleName); } else { resourcesComponent.UnloadBundle(assetBundleName); } }
//省略 前缀 加载资源 public static UnityEngine.Object AwayPrefixGetAsset(this ResourcesComponent resourcesComponent, string assetBundleName, string prefab) { assetBundleName = assetBundleName.ToLower(); if (ResourcesComponent.bundlesNameDictionary.ContainsKey(assetBundleName)) { return(resourcesComponent.BundleNameGetAsset(ResourcesComponent.bundlesNameDictionary[assetBundleName] + "/" + assetBundleName, prefab)); } else { return(resourcesComponent.BundleNameGetAsset(assetBundleName, prefab)); } }
public void Awake(GameObject panel) { this.Panel = panel; _poker = this.Panel.Get <GameObject>("Poker"); _handCards = this.Panel.Get <GameObject>("HandCards"); _pokerNum = _poker?.GetComponentInChildren <Text>(); //加载AB包 ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"{HANDCARD_NAME}.unity3d"); resourcesComponent.LoadBundle($"{PLAYCARD_NAME}.unity3d"); resourcesComponent.LoadBundle($"{CardHelper.ATLAS_NAME}.unity3d"); }
public void AddPackage(string type) { #if UNITY_EDITOR UIPackage uiPackage = UIPackage.AddPackage($"{FUI_PACKAGE_DIR}/{type}"); #else string uiBundleName = type.StringToAB(); ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle(uiBundleName); AssetBundle assetBundle = resourcesComponent.GetAssetBundle(uiBundleName); UIPackage uiPackage = UIPackage.AddPackage(assetBundle); #endif this.packages.Add(type, uiPackage); }
public void Awake() { m_tank = this.GetParent <Tank>(); wheels = m_tank.GameObject.FindComponentInChildren <Transform>("wheels"); tracks = m_tank.GameObject.FindComponentInChildren <Transform>("tracks"); motorAudioSource = m_tank.GameObject.GetComponent <AudioSource>(); if (this.motorAudioSource == null) { motorAudioSource = m_tank.GameObject.AddComponent <AudioSource>(); } motorAudioSource.playOnAwake = false; motorAudioSource.spatialBlend = 1; motorAudioSource.volume = GameSettingInfo.AudioVolume(); ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); Game.Scene.GetComponent <ResourcesComponent>().LoadBundle($"Unit.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit"); Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle($"Unit.unity3d"); motorClip = bundleGameObject.Get <AudioClip>("motor"); this.motorAudioSource.loop = true; this.motorAudioSource.clip = this.motorClip; axleInfos = new List <AxleInfo>(2); // 前轮 AxleInfo axleInfo = new AxleInfo(); axleInfo.leftWheel = m_tank.GameObject.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelL1"); axleInfo.rightWheel = m_tank.GameObject.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelR1"); axleInfo.montor = false; axleInfo.steering = true; this.axleInfos.Add(axleInfo); axleInfo = new AxleInfo(); axleInfo.leftWheel = m_tank.GameObject.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelL2"); axleInfo.rightWheel = m_tank.GameObject.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelR2"); axleInfo.montor = true; axleInfo.steering = false; this.axleInfos.Add(axleInfo); }
//加载声音 private async ETTask <SoundData> LoadSound(string soundName) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); if (!abSounds.ContainsKey(soundName) || abSounds[soundName] == null) { abSounds.Add(soundName, UnityEngine.Object.Instantiate( (resourcesComponent.LoadAsset <GameObject>(ABPathUtilities.GetSoundPath("Sound"))) .GetTargetObjectFromRC <GameObject>(soundName)) .GetComponent <SoundData>()); } return(abSounds[soundName]); }
//加载声音 private async ETTask <SoundData> LoadSound(string soundName) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); if (!abSounds.ContainsKey(soundName) || abSounds[soundName] == null) { await resourcesComponent.CacheBundleAsync(soundName); var prefab = UnityEngine.Object.Instantiate((GameObject)resourcesComponent.GetAsset(SoundPrefab)); prefab.name = soundName; abSounds.Add(soundName, prefab.GetComponent <SoundData>()); abSounds[soundName].GetAudio().clip = (AudioClip)resourcesComponent.GetAsset(soundName); } return(abSounds[soundName]); }
private void InitPhysical() { wheels = m_tank.FindComponentInChildren <Transform>("wheels"); tracks = m_tank.FindComponentInChildren <Transform>("tracks"); motorAudioSource = m_tank.GetComponent <AudioSource>(); if (motorAudioSource == null) { motorAudioSource = m_tank.AddComponent <AudioSource>(); } motorAudioSource.spatialBlend = 1; motorAudioSource.volume = GameSettingInfo.AudioVolume(); ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); //Game.Scene.GetComponent<ResourcesComponent>().LoadBundle($"Unit.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(AssetBundleName.Unit, PrefabName.Unit); //Game.Scene.GetComponent<ResourcesComponent>().UnloadBundle($"Unit.unity3d"); motorClip = bundleGameObject.Get <AudioClip>("motor"); motorAudioSource.loop = true; motorAudioSource.clip = this.motorClip; axleInfos = new List <AxleInfo>(2); // 前轮 转向轮 AxleInfo axleInfo = new AxleInfo(); axleInfo.leftWheel = m_tank.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelL1"); axleInfo.rightWheel = m_tank.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelR1"); axleInfo.montor = false; axleInfo.steering = true; this.axleInfos.Add(axleInfo); // 后轮 动力轮 axleInfo = new AxleInfo(); axleInfo.leftWheel = m_tank.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelL2"); axleInfo.rightWheel = m_tank.FindComponentInChildren <WheelCollider>("PhysicalBody/wheelR2"); axleInfo.montor = true; axleInfo.steering = false; this.axleInfos.Add(axleInfo); }
// 加载资源 public static async Task LoadRes() { string fileName = ""; try { string versionPath = Path.Combine(PathHelper.AppHotfixResPath, "Version.txt"); ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); VersionConfig localVersionConfig = JsonHelper.FromJson <VersionConfig>(File.ReadAllText(versionPath)); foreach (var data in localVersionConfig.FileInfoDict) { fileName = data.Value.File; if ((fileName.Equals("Version.txt")) || (fileName.Equals("StreamingAssets"))) { continue; } await resourcesComponent.LoadBundleAsync(fileName); } //foreach (var str in fileList) //{ // fileName = str; // if ((fileName.Equals("Version.txt")) || // (fileName.Equals("StreamingAssets"))) // { // continue; // } // try // { // await resourcesComponent.LoadBundleAsync(fileName); // } // catch (Exception ex) // { // Log.Debug("LoadRes异常:" + ex + "----" + fileName); // } //} } catch (Exception ex) { Log.Debug("LoadRes异常:" + ex + "----" + fileName); ToastScript.createToast("加载音频出错:" + fileName); } }
public void Update() { ClientPredictionComponent clientPredictionComponent = Game.Scene.GetComponent <ClientPredictionComponent>(); UnitStateComponent unitStateComponent = this.Entity.GetComponent <UnitStateComponent>(); UnitState serverState; if (this.isLocal) { serverState = clientPredictionComponent.VerifyState; } else { //serverState = unitStateComponent.GetServerState(); serverState = unitStateComponent.State; } if (this.Instance == null && serverState.Frame > 0) { ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset("Unit.unity3d", "Unit"); GameObject prefab = bundleGameObject.Get <GameObject>("Skeleton"); GameObject instance = UnityEngine.Object.Instantiate(prefab); GameObject parent = GameObject.Find($"/Global/Unit"); instance.transform.SetParent(parent.transform, false); this.Instance = instance; this.anim = instance.GetComponent <Animator>(); if (this.isLocal) { ETModel.Game.Scene.AddComponent <CameraComponent>().Unit = this.Instance; } } else if (this.Instance != null) { if (this.isLocal) { this.State = clientPredictionComponent.PredictedState; } else { this.State = unitStateComponent.State; } UpdateInstance(); } }
public async ETTask AddPackageAsync(string type) { #if UNITY_EDITOR await ETTask.CompletedTask; UIPackage uiPackage = UIPackage.AddPackage($"{FUI_PACKAGE_DIR}/{type}"); #else string uiBundleName = type.StringToAB(); ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); await resourcesComponent.LoadBundleAsync(uiBundleName); AssetBundle assetBundle = resourcesComponent.GetAssetBundle(uiBundleName); UIPackage uiPackage = UIPackage.AddPackage(assetBundle); #endif this.packages.Add(type, uiPackage); }
public void Awake() { if (string.IsNullOrEmpty(abName)) { Log.Error(this.GetType() + "/Awake() 初始化Ui界面失败,Gobj为空!"); return; } //string bundleName = this.abName.ToLower(); string bundleName = abName; ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"{bundleName }.unity3d"); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset($"{bundleName }.unity3d", $"{bundleName }"); GObj = UnityEngine.Object.Instantiate(bundleGameObject); InitUI(); }
public static GameObject Create(Vector3 pos) { // 创建爆炸效果 ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>(); //resourcesComponent.LoadBundle(AssetBundleName.Unit); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(AssetBundleName.Unit, PrefabName.Unit); //resourcesComponent.UnloadBundle(AssetBundleName.Unit); GameObject explosion = bundleGameObject.Get <GameObject>(PrefabName.BulletBoomEffect); GameObject explosionGameObject = resourcesComponent.NewObj(PrefabType.BulletBoom, explosion); explosionGameObject.SetActive(false); explosionGameObject.transform.position = pos; // 创建爆炸音效 AudioClip audio = bundleGameObject.Get <AudioClip>(PrefabName.BulletBoomAudio); AudioSource audioSource = explosionGameObject.GetComponent <AudioSource>(); if (audioSource == null) { audioSource = explosionGameObject.AddComponent <AudioSource>(); audioSource.spatialBlend = 1; audioSource.loop = false; audioSource.clip = audio; audioSource.playOnAwake = true; audioSource.volume = GameSettingInfo.AudioVolume(); } explosionGameObject.SetActive(true); FairyGUI.Timers.inst.Add(7f, 1, (_) => { resourcesComponent.RecycleObj(PrefabType.BulletBoom, explosionGameObject); }); return(explosionGameObject); }
public static UI Create(string type, UI parent) { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle($"{type}.unity3d"); GameObject prefab = (GameObject)resourcesComponent.GetAsset($"{type}.unity3d", $"{type}"); GameObject interaction = UnityEngine.Object.Instantiate(prefab); interaction.layer = LayerMask.NameToLayer("UI"); UI ui = ComponentFactory.Create <UI, GameObject>(interaction); parent.Add(ui); ui.GameObject.transform.SetParent(parent.GameObject.transform, false); ui.AddComponent <LandInteractionComponent>(); return(ui); }
public static UI Create() { try { ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent <ResourcesComponent>(); resourcesComponent.LoadBundle(UIType.UILobby.StringToAB()); GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(UIType.UILobby.StringToAB(), UIType.UILobby); GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject); UI ui = ComponentFactory.Create <UI, string, GameObject>(UIType.UILobby, gameObject, false); ui.AddComponent <UILobbyComponent>(); return(ui); } catch (Exception e) { Log.Error(e); return(null); } }