public void UnpackRequest(AssetLoadRequest <T> req, UnityObject unityObj) { if (_isDisposed) { _logger.Error("Call UnpackRequest On Disposed Asset Load Request Batch!"); return; } _loadedUnityObjects.Add(unityObj); req.ReferenceBatch = null; _referenceCount--; if (_referenceCount <= 0) { _referenceCount = 0; if (_onLoaded != null) { try { _onLoaded(_source, _loadedUnityObjects); } catch (Exception e) { _logger.Error("Batch OnLoaded Callback Error", e); } } Free(this); } }
protected override IEnumerator LoadAssets() { AssetReference weaponIllustrationReference = m_definition.GetWeaponIllustrationReference(); AssetLoadRequest <Sprite> assetReferenceRequest = weaponIllustrationReference.LoadFromAssetBundleAsync <Sprite>(AssetBundlesUtility.GetUICharacterResourcesBundleName()); while (!assetReferenceRequest.get_isDone()) { yield return(null); } if (AssetManagerError.op_Implicit(assetReferenceRequest.get_error()) != 0) { Log.Error($"Error while loading illustration for {((object)m_definition).GetType().Name} {m_definition.get_name()} error={assetReferenceRequest.get_error()}", 47, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\UI\\Player\\DeckRoot\\WeaponRibbonItem.cs"); yield break; } m_visual.set_sprite(assetReferenceRequest.get_asset()); AssetReference uIWeaponButtonReference = m_definition.GetUIWeaponButtonReference(); AssetLoadRequest <Material> matAssetReferenceRequest = uIWeaponButtonReference.LoadFromAssetBundleAsync <Material>("core/ui/characters/heroes"); while (!matAssetReferenceRequest.get_isDone()) { yield return(null); } if (AssetManagerError.op_Implicit(matAssetReferenceRequest.get_error()) != 0) { Log.Error(string.Format("Error while loading material {0} error={1}", "core/ui/characters/weaponbutton", assetReferenceRequest.get_error()), 63, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\UI\\Player\\DeckRoot\\WeaponRibbonItem.cs"); yield break; } m_equipedMaterial = matAssetReferenceRequest.get_asset(); m_shine.set_color(m_definition.deckBuildingWeaponShine); }
private IEnumerator Load(string guid, string bundleName, UIResourceDisplayMode displayMode) { loadState = UIResourceLoadState.Loading; AssetBundleLoadRequest bundleLoadRequest = AssetManager.LoadAssetBundle(bundleName); while (!bundleLoadRequest.get_isDone()) { yield return(null); } if (AssetManagerError.op_Implicit(bundleLoadRequest.get_error()) != 0) { loadState = UIResourceLoadState.Error; m_pendingBundleName = string.Empty; if (m_resourceConsumer != null) { m_resourceConsumer.UnRegister(this); m_resourceConsumer = null; } Log.Error($"Could not load bundle named '{bundleName}': {bundleLoadRequest.get_error()}", 226, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\UI\\Components\\UIResourceLoader.cs"); m_coroutine = null; yield break; } AssetLoadRequest <T> assetLoadRequest = AssetManager.LoadAssetAsync <T>(guid, bundleName); while (!assetLoadRequest.get_isDone()) { yield return(null); } if (AssetManagerError.op_Implicit(assetLoadRequest.get_error()) != 0) { AssetManager.UnloadAssetBundle(bundleName); loadState = UIResourceLoadState.Error; m_pendingBundleName = string.Empty; if (m_resourceConsumer != null) { m_resourceConsumer.UnRegister(this); m_resourceConsumer = null; } Log.Error($"Could not load asset with guid {guid} from bundle named '{bundleName}': {assetLoadRequest.get_error()}", 253, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\UI\\Components\\UIResourceLoader.cs"); m_coroutine = null; yield break; } T asset = assetLoadRequest.get_asset(); yield return(Apply(asset, displayMode)); if (m_loadedBundleName.Length != 0) { AssetManager.UnloadAssetBundle(m_loadedBundleName); } loadState = UIResourceLoadState.Loaded; m_pendingBundleName = string.Empty; m_loadedBundleName = bundleName; if (m_resourceConsumer != null) { m_resourceConsumer.UnRegister(this); m_resourceConsumer = null; } m_coroutine = null; }
public void AddToCompleteQueue(AssetLoadRequest asset) { lock (_syncObj) { _internalCompletedQueue.Enqueue(asset); } }
public static void LoadAsync <T>(string path, OnLoadedAsset onLoaded) where T : UnityEngine.Object { if (mRequests.ContainsKey(path)) { AssetLoadRequest r = mRequests[path]; r.callback += onLoaded; return; } ResourceRequest request = Resources.LoadAsync <T>(path); if (request.isDone) { if (onLoaded != null) { onLoaded(request.asset); } return; } AssetLoadRequest alr = new AssetLoadRequest(); alr.path = path; alr.callback = onLoaded; alr.request = request; mRequests.Add(path, alr); mRequestList.Add(alr); GameApp.Instance.StartCoroutine(OnLoading(alr)); }
public static IEnumerator LoadIllustrationAsync <T>(this EditableData definition, string bundleName, AssetReference assetReference, Action <T, string> onLoaded) where T : Object { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) AssetBundleLoadRequest bundleLoadRequest = AssetManager.LoadAssetBundle(bundleName); while (!bundleLoadRequest.get_isDone()) { yield return(null); } if (AssetManagerError.op_Implicit(bundleLoadRequest.get_error()) != 0) { Log.Error($"Error while loading bundle '{bundleName}' for {((object)definition).GetType().Name} {definition.get_name()} error={bundleLoadRequest.get_error()}", 36, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Data\\Definitions\\ICastableDefinition.cs"); onLoaded?.Invoke(default(T), null); yield break; } AssetLoadRequest <T> assetLoadRequest = assetReference.LoadFromAssetBundleAsync <T>(bundleName); while (!assetLoadRequest.get_isDone()) { yield return(null); } if (AssetManagerError.op_Implicit(assetLoadRequest.get_error()) != 0) { Log.Error($"Error while loading illustration for {((object)definition).GetType().Name} {definition.get_name()} error={assetLoadRequest.get_error()}", 50, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Data\\Definitions\\ICastableDefinition.cs"); onLoaded?.Invoke(default(T), bundleName); } else { onLoaded?.Invoke(assetLoadRequest.get_asset(), bundleName); } }
public IEnumerator ChangeAnimatedCharacterData(int skinId, Gender gender) { if (!RuntimeData.characterSkinDefinitions.TryGetValue(skinId, out CharacterSkinDefinition characterSkinDefinition)) { Log.Error($"Could not find character skin definition with id {skinId}.", 211, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Maps\\Objects\\CharacterObject.cs"); yield break; } BundleCategory bundleCategory = characterSkinDefinition.bundleCategory; string bundleName = AssetBundlesUtility.GetAnimatedCharacterDataBundle(bundleCategory); AssetBundleLoadRequest bundleLoadRequest = AssetManager.LoadAssetBundle(bundleName); m_activeCharacterDataBundleCategory = bundleCategory; while (!bundleLoadRequest.get_isDone()) { yield return(null); } if (AssetManagerError.op_Implicit(bundleLoadRequest.get_error()) != 0) { Log.Error($"Failed to load asset bundle named '{bundleName}' for character skin {characterSkinDefinition.get_displayName()} ({characterSkinDefinition.get_id()}): {bundleLoadRequest.get_error()}", 230, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Maps\\Objects\\CharacterObject.cs"); yield break; } AssetReference animatedCharacterDataReference = characterSkinDefinition.GetAnimatedCharacterDataReference(gender); AssetLoadRequest <AnimatedCharacterData> animatedCharacterDataLoadRequest = animatedCharacterDataReference.LoadFromAssetBundleAsync <AnimatedCharacterData>(bundleName); while (!animatedCharacterDataLoadRequest.get_isDone()) { yield return(null); } if (AssetManagerError.op_Implicit(animatedCharacterDataLoadRequest.get_error()) != 0) { AssetManager.UnloadAssetBundle(bundleName); m_activeCharacterDataBundleCategory = BundleCategory.None; Log.Error(string.Format("Failed to load requested {0} asset from bundle '{1}' for character skin {2} ({3}): {4}", "AnimatedCharacterData", bundleName, characterSkinDefinition.get_displayName(), characterSkinDefinition.get_id(), animatedCharacterDataLoadRequest.get_error()), 247, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Maps\\Objects\\CharacterObject.cs"); yield break; } AnimatedCharacterData newAnimatedCharacterData = animatedCharacterDataLoadRequest.get_asset(); yield return(newAnimatedCharacterData.LoadTimelineResources()); AnimatedCharacterData animatedCharacterData = GetAnimatedCharacterData(); if (null != animatedCharacterData) { string animatedCharacterDataBundle = AssetBundlesUtility.GetAnimatedCharacterDataBundle(m_animatedCharacterDataBundleCategory); animatedCharacterData.UnloadTimelineResources(); AssetManager.UnloadAssetBundle(animatedCharacterDataBundle); m_animatedCharacterDataBundleCategory = BundleCategory.None; } SetAnimatedCharacterData(newAnimatedCharacterData); m_animatedCharacterDataBundleCategory = m_activeCharacterDataBundleCategory; m_activeCharacterDataBundleCategory = BundleCategory.None; IAnimator2D animator = GetAnimator(); int animationFrame = animator.get_currentFrame(); yield return(SetAnimatorDefinition()); animator.set_currentFrame(animationFrame); }
public static void RemoveRequest(string path) { if (mRequests.ContainsKey(path)) { AssetLoadRequest r = mRequests[path]; r.callback = null; mRequests.Remove(path); } }
public void PackRequest(AssetLoadRequest <T> req) { if (_source == null) { _source = req.Source; } req.ReferenceBatch = this; _referenceCount++; }
/// <summary> /// 加载Bundle /// </summary> /// <param name="assetName"></param> /// <param name="onComplete"></param> /// <param name="isSub"></param> internal static void LoadBundle(string assetName, UseGameObjectAssetDelegate onComplete, bool isSub) { if (!instance.data.assetBundlePath.ContainsKey(assetName)) { Debug.LogWarning("--Toto-- AssetBundleLoadManager->UseGameObjectAsset: '" + assetName + "' asset does not exist."); return; } // 判断回收站 if (instance.mRecycleBundleCached.ContainsKey(assetName)) { var list = instance.mRecycleBundleCached[assetName]; if (list.Count > 0) { Bundle bundleInstantiate = list.Dequeue(); bundleInstantiate.gameObject.SetActive(true); if (onComplete != null) { onComplete(assetName, bundleInstantiate); } return; } } // 判断缓存 if (instance.mAssetCached.ContainsKey(assetName)) { Bundle b = (Bundle)instance.mAssetCached[assetName]; if (b != null) { if (onComplete != null) { onComplete(assetName, InstantiateBundle(b)); } } return; } AssetLoadRequest loadRequest = (AssetLoadRequest)FindLoadRequestByName(assetName); if (loadRequest != null) { instance.mAssetLoadRequestWaitList.Add(new AssetLoadRequestWait() { assetName = assetName, onComplete = onComplete }); return; } string abPath = instance.data.assetBundlePath[assetName]; AssetLoadRequest abLoadRequest = new AssetLoadRequest(); abLoadRequest.assetName = assetName; abLoadRequest.onComplete = onComplete; abLoadRequest.isSub = isSub; instance.mAssetLoadRequestList.Add(abLoadRequest); // 添加至资源请求list instance.StartCoroutine(instance.LoadAssetBundle(abPath, abLoadRequest)); }
public AssetLoadRequest <T> LoadAsset <T>(string bundle, string asset) where T : UnityEngine.Object { if (bundles.TryGetValue(bundle, out IBundle assetBundle)) { AssetLoadRequest <T> request = new AssetLoadRequest <T> { BundleName = bundle, AssetName = asset }; assetBundle.HandleRequest(request); return(request); } return(AssetLoadRequest <T> .Empty); }
public void LoadSceneAsync(AssetInfo assetInfo, bool isAdditive) { _logger.InfoFormat("LoadSeneAsync {0}", assetInfo); var req = AssetLoadRequest <object> .Alloc(); req.Source = null; req.AssetInfo = assetInfo; req.OnLoaded = null; req.RequestType = ELoadRequestType.Scene; req.IsAdditiveScene = isAdditive; _pendingRequests.AddLast(req); }
public IEnumerator LoadResources() { if (!m_prefabReference.get_hasValue()) { yield break; } GameObject asset; if (string.IsNullOrEmpty(m_assetBundleName)) { AssetReferenceRequest <GameObject> assetReferenceRequest2 = m_prefabReference.LoadFromResourcesAsync <GameObject>(); while (!assetReferenceRequest2.get_isDone()) { yield return(null); } asset = assetReferenceRequest2.get_asset(); } else { AssetBundleLoadRequest bundleRequest = AssetManager.LoadAssetBundle(m_assetBundleName); while (!bundleRequest.get_isDone()) { yield return(null); } if (AssetManagerError.op_Implicit(bundleRequest.get_error()) != 0) { Log.Error($"Could not load bundle named '{m_assetBundleName}': {bundleRequest.get_error()}", 99, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Animations\\VisualEffectPlayableAsset.cs"); yield break; } m_loadedAssetBundle = true; AssetLoadRequest <GameObject> assetReferenceRequest = m_prefabReference.LoadFromAssetBundleAsync <GameObject>(m_assetBundleName); while (!assetReferenceRequest.get_isDone()) { yield return(null); } if (AssetManagerError.op_Implicit(assetReferenceRequest.get_error()) != 0) { Log.Error($"Could not load requested asset ({m_prefabReference.get_value()}) from bundle named '{m_assetBundleName}': {assetReferenceRequest.get_error()}", 113, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Animations\\VisualEffectPlayableAsset.cs"); yield break; } asset = assetReferenceRequest.get_asset(); } VisualEffect component = asset.GetComponent <VisualEffect>(); if (null == component) { Log.Error("Could not use prefab because it doesn't have a VisualEffect component.", 123, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Animations\\VisualEffectPlayableAsset.cs"); yield break; } VisualEffectFactory.PreparePool(asset); m_prefab = component; }
public void LoadAssetBundleAsync(string bundleName) { var req = AssetLoadRequest <object> .Alloc(); req.Source = null; req.OnLoaded = null; req.AssetInfo = new AssetInfo() { BundleName = bundleName, AssetName = null }; req.RequestType = ELoadRequestType.Bundle; _pendingRequests.AddLast(req); }
private IEnumerator LoadCharacterSkin() { if (!string.IsNullOrEmpty(m_lastLoadedCharacterBundle)) { this.UnloadAssetBundle(m_lastLoadedCharacterBundle, true, true); m_lastLoadedCharacterBundle = null; } PlayerData instance = PlayerData.instance; Gender gender = instance.gender; Id <CharacterSkinDefinition> skin = instance.Skin; if (skin == null || !RuntimeData.characterSkinDefinitions.TryGetValue(skin.value, out CharacterSkinDefinition characterSkinDefinition)) { yield break; } BundleCategory bundleCategory = characterSkinDefinition.bundleCategory; string bundleName = m_lastLoadedCharacterBundle = AssetBundlesUtility.GetAnimatedCharacterDataBundle(bundleCategory); AssetBundleLoadRequest bundleLoadRequest = this.LoadAssetBundle(bundleName); while (!bundleLoadRequest.get_isDone()) { yield return(null); } if (AssetManagerError.op_Implicit(bundleLoadRequest.get_error()) != 0) { Log.Error($"Failed to load asset bundle named '{bundleName}' for character skin {characterSkinDefinition.get_displayName()} ({characterSkinDefinition.get_id()}): {bundleLoadRequest.get_error()}", 253, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\States\\HavreDimension\\HavreDimensionMainState.cs"); yield break; } AssetReference animatedCharacterDataReference = characterSkinDefinition.GetAnimatedCharacterDataReference(gender); AssetLoadRequest <AnimatedCharacterData> animatedCharacterDataLoadRequest = animatedCharacterDataReference.LoadFromAssetBundleAsync <AnimatedCharacterData>(bundleName); while (!animatedCharacterDataLoadRequest.get_isDone()) { yield return(null); } if (AssetManagerError.op_Implicit(animatedCharacterDataLoadRequest.get_error()) != 0) { this.UnloadAssetBundle(bundleName, true, true); Log.Error(string.Format("Failed to load {0} asset from bundle '{1}' for character skin {2} ({3}): {4}", "AnimatedCharacterData", bundleName, characterSkinDefinition.get_displayName(), characterSkinDefinition.get_id(), animatedCharacterDataLoadRequest.get_error()), 269, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\States\\HavreDimension\\HavreDimensionMainState.cs"); yield break; } AnimatedCharacterData animatedCharacterData = animatedCharacterDataLoadRequest.get_asset(); yield return(animatedCharacterData.LoadTimelineResources()); AnimatedFightCharacterData animatedFightCharacterData = animatedCharacterData as AnimatedFightCharacterData; AnimatedObjectDefinition animatedObjectDefinition = animatedFightCharacterData.animatedObjectDefinition; m_havreMap.character.SetCharacterData(animatedFightCharacterData, animatedObjectDefinition); m_loadCharacterCoroutine = null; }
private IEnumerator DoLoadRequest <T>(AssetLoadRequest <T> request) where T : UnityEngine.Object { if (bundle == null) { yield return(Load()); } if (bundle != null) { var req = bundle.LoadAssetAsync <T>(request.AssetName); yield return(req); request.Asset = req.asset as T; } request.LoadFinsh = true; }
public void OnXMLLoadComplete(AssetLoadRequest inValue) { XMLAssetLoader xmlAssetLoader = inValue as XMLAssetLoader; CombinedData data = xmlAssetLoader?.Content as CombinedData; if (data != null) { foreach (BaseData instance in data.Data) { DataStore.AddData(instance); } } OnLoadingComplete(0); }
private void PumpAssetLoading() { lock (_syncObj) { if (_internalAssetQueue.Count > 0) { AssetLoadRequest task = _internalAssetQueue.Dequeue(); if (task.UseCustomFunction) { Action handler = null; handler = () => { // ReSharper disable once DelegateSubtraction task.OnDone -= handler; OnTaskCompletedAdd(task); }; task.OnDone += handler; task.Load(); _runningTaskCount++; return; } if (_runningTaskCount == MAXJOBS) { return; } if (task.Block) { task.Load(); while (!task.IsDone) { } task.OnComplete(); } else { QueueUserWorkItem(task); } } } }
static IEnumerator OnLoading(AssetLoadRequest request) { while (!request.request.isDone) { yield return(null); } if (request.callback != null) { request.callback(request.request.asset); } else { UnityEngine.Object.Destroy(request.request.asset); } mRequests.Remove(request.path); mRequestList.Remove(request); }
private void QueueUserWorkItem(AssetLoadRequest asset) { Action completionTask = () => { asset.Load(); while (!asset.IsDone) { } OnTaskCompletedAdd(asset); }; _runningTaskCount++; ThreadPool.QueueUserWorkItem(_ => completionTask()); }
public bool RequestAssetLoad(AssetLoadRequest inReuqest) { // should there be a max here ? if (_internalAssetQueue.Count >= 100) { // we went over the max amount of assets that can be loaded or requested ? return(false); } lock (_syncObj) { _internalAssetQueue.Enqueue(inReuqest); } PumpAssetLoading(); return(true); }
private IEnumerator LoadWeaponInfos(WeaponDefinition definition) { AssetReference weaponIllustrationReference = definition.GetWeaponIllustrationReference(); m_weaponTextField.SetText(definition.i18nNameId); m_weaponLevelField.SetText(68066, new IndexedValueProvider(m_level.ToString())); AssetLoadRequest <Sprite> assetReferenceRequest = weaponIllustrationReference.LoadFromAssetBundleAsync <Sprite>(AssetBundlesUtility.GetUICharacterResourcesBundleName()); while (!assetReferenceRequest.get_isDone()) { yield return(null); } if (AssetManagerError.op_Implicit(assetReferenceRequest.get_error()) != 0) { Log.Error($"Error while loading illustration for {((object)definition).GetType().Name} {definition.get_name()} error={assetReferenceRequest.get_error()}", 305, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\UI\\Player\\DeckRoot\\DeckUIRoot.cs"); yield break; } WeaponData value = new WeaponData(definition, m_level); m_weaponVisual.SetValue(value); m_weaponPassiveText.SetText(definition.i18nDescriptionId, new FightValueProvider(definition, m_level)); m_pedestalWeaponCellRenderer.SetValue(value); if (definition != null) { List <Id <SpellDefinition> > list = definition.spells.ToList(); if (list.Count != 0 && RuntimeData.spellDefinitions.TryGetValue(list[0].value, out SpellDefinition value2)) { SpellData spellData = new SpellData(value2, m_level); m_pedestalSpellCellRenderer.SetValue(spellData); m_equippedFX.SetElement(value2.element); m_spellRenderer.SetValue(new SpellData(value2, m_level)); string text = RuntimeData.FormattedText(spellData.definition.i18nNameId); m_spellName.SetText(33557, new IndexedValueProvider(text)); m_spellDescription.SetText(spellData.definition.i18nDescriptionId, new FightValueProvider(spellData.definition, m_level)); int valueWithLevel = definition.movementPoints.GetValueWithLevel(m_level); int valueWithLevel2 = definition.life.GetValueWithLevel(m_level); int valueWithLevel3 = definition.actionValue.GetValueWithLevel(m_level); m_strengthField.SetText(valueWithLevel3.ToString()); m_lifeField.SetText(valueWithLevel2.ToString()); m_moveField.SetText(valueWithLevel.ToString()); } } }
public void UnpackRequest(AssetLoadRequest <T> req, UnityObject unityObj) { if (_isDisposed) { _logger.Error("Call UnpackRequest On Disposed Asset Load Request Batch!"); return; } _loadedUnityObjects[req.BatchIndex] = unityObj; unityObj.SetActive(false); req.ReferenceBatch = null; _referenceCount--; if (_referenceCount <= 0) { _referenceCount = 0; if (_onLoaded != null) { try { if (_autoActive) { for (var i = 0; i < _loadedUnityObjects.Count; i++) { var unity = _loadedUnityObjects[i]; if (unity != null) { unity.SetActive(true); } } } _onLoaded(_source, _loadedUnityObjects); } catch (Exception e) { _logger.Error("Batch OnLoaded Callback Error", e); } } Free(this); } }
private IEnumerator LoadGod() { if (!string.IsNullOrEmpty(m_lastLoadedGodBundle)) { this.UnloadAssetBundle(m_lastLoadedGodBundle, true, true); m_lastLoadedGodBundle = null; } God god = PlayerData.instance.god; if (!RuntimeData.godDefinitions.TryGetValue(god, out GodDefinition value)) { yield break; } AssetReference statuePrefabReference = value.statuePrefabReference; string bundleName = m_lastLoadedGodBundle = AssetBundlesUtility.GetUIGodsResourcesBundleName(); AssetBundleLoadRequest bundleRequest = this.LoadAssetBundle(bundleName); while (!bundleRequest.get_isDone()) { yield return(null); } if (AssetManagerError.op_Implicit(bundleRequest.get_error()) != 0) { Log.Error($"Could not load bundle named '{bundleName}': {bundleRequest.get_error()}", 196, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\States\\HavreDimension\\HavreDimensionMainState.cs"); yield break; } AssetLoadRequest <GameObject> assetReferenceRequest = statuePrefabReference.LoadFromAssetBundleAsync <GameObject>(bundleName); while (!assetReferenceRequest.get_isDone()) { yield return(null); } if (AssetManagerError.op_Implicit(assetReferenceRequest.get_error()) != 0) { Log.Error($"Could not load requested asset ({statuePrefabReference.get_value()}) from bundle named '{bundleName}': {assetReferenceRequest.get_error()}", 208, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\States\\HavreDimension\\HavreDimensionMainState.cs"); yield break; } GameObject asset = assetReferenceRequest.get_asset(); m_havreMap.godZaap.SetStatue(asset); m_loadGodCoroutine = null; }
public override void Update(float time, float deltaTime) { base.Update(time, deltaTime); // we have completed lets pump the asset queue again! PumpAssetLoading(); while (_internalCompletedQueue.Count != 0) { AssetLoadRequest cpTask = _internalCompletedQueue.Dequeue(); if (cpTask.HasFailed) { cpTask.OnFailure(); } else { cpTask.OnComplete(); } } }
public void LoadAsset(string assetName, string bundleName, Action <string, AssetBundle> onComplete) { AssetLoadRequest request = null; if (requests.TryGetValue(assetName, out request)) { request.onComplete += onComplete; return; } AssetLoadRequest newRequest = new AssetLoadRequest(); newRequest.onComplete += onComplete; newRequest.AssetName = assetName; Bundle bundle = GetBundle(bundleName); if (bundle == null) { bundle = DownLoadBundle(bundleName); } newRequest.AddDependentBundle(bundle); string[] dependencyBundleNames = manifest.GetAllDependencies(bundleName); foreach (var name in dependencyBundleNames) { Bundle dependBundle = GetBundle(name); if (dependBundle == null) { dependBundle = DownLoadBundle(name); } newRequest.AddDependentBundle(dependBundle); } requests.Add(assetName, newRequest); }
private static IEnumerator PreloadEffectAssets <K, V>(SerializableDictionaryLogic <K, AssetReference> effects, Dictionary <K, V> effectCache, string bundleName) where V : ScriptableEffect { int count = ((Dictionary <K, AssetReference>)effects).Count; if (count != 0) { AssetLoadRequest <V>[] loadRequests = new AssetLoadRequest <V> [count]; int num = 0; foreach (AssetReference value in ((Dictionary <K, AssetReference>)effects).Values) { AssetReference current = value; if (current.get_hasValue()) { loadRequests[num] = current.LoadFromAssetBundleAsync <V>(bundleName); } num++; } yield return(EnumeratorUtility.ParallelRecursiveImmediateExecution((IEnumerator[])loadRequests)); num = 0; foreach (K key in ((Dictionary <K, AssetReference>)effects).Keys) { AssetLoadRequest <V> val = loadRequests[num]; num++; if (val != null) { if (AssetManagerError.op_Implicit(val.get_error()) != 0) { Log.Error($"Failed to load effect for '{key}': {val.get_error()}", 608, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\Fight\\FightSpellEffectFactory.cs"); } else { effectCache.Add(key, val.get_asset()); } } } } }
public void LoadAsset(string assetName, string bundleName, Action<string, AssetBundle> onComplete) { AssetLoadRequest request = null; if (requests.TryGetValue(assetName, out request)) { request.onComplete += onComplete; return; } AssetLoadRequest newRequest = new AssetLoadRequest(); newRequest.onComplete += onComplete; newRequest.AssetName = assetName; Bundle bundle = GetBundle(bundleName); if (bundle == null) { bundle = DownLoadBundle(bundleName); } newRequest.AddDependentBundle(bundle); string[] dependencyBundleNames = manifest.GetAllDependencies(bundleName); foreach (var name in dependencyBundleNames) { Bundle dependBundle = GetBundle(name); if (dependBundle == null) { dependBundle = DownLoadBundle(name); } newRequest.AddDependentBundle(dependBundle); } requests.Add(assetName, newRequest); }
public void OnServerPacker(AssetLoadRequest inValue) { if (!_running) { return; } if (!inValue.HasFailed) { AsyncPollingWebLoader asyncPollingWebLoader = inValue as AsyncPollingWebLoader; byte[] jsonData = asyncPollingWebLoader?.WebData; if (jsonData != null) { string jsonString = Encoding.UTF8.GetString(jsonData); try { GameMessageList mm = new GameMessageList(); ThriftMessageSerialize.DeSerialize(mm, jsonString); foreach (string item in mm.Messages) { LibCommon.Network.Types.GameMessage gm = new LibCommon.Network.Types.GameMessage(); ThriftMessageSerialize.DeSerialize(gm, item); ClientQueue.Enqueue(gm); } } catch (Exception ex) { Debug.LogErrorFormat("Error Message: {0} {1}", ex.Message, jsonString); } } } _requestingCurrently = false; }
public void OnXMLFailedLoad(AssetLoadRequest inValue) { }
public void HandleRequest <T>(AssetLoadRequest <T> requst) where T : UnityEngine.Object { requst.Asset = Load <T>(requst.AssetName); requst.LoadFinsh = true; }
/// <summary> /// 加载Bundle /// </summary> /// <param name="assetName"></param> /// <param name="onComplete"></param> /// <param name="isSub"></param> internal static void LoadBundle(string assetName, UseGameObjectAssetDelegate onComplete, bool isSub) { if (!instance.data.assetBundlePath.ContainsKey(assetName)) { Debug.LogWarning("--Toto-- AssetBundleLoadManager->UseGameObjectAsset: '" + assetName + "' asset does not exist."); return; } // 判断回收站 if (instance.mRecycleBundleCached.ContainsKey(assetName)) { var list = instance.mRecycleBundleCached[assetName]; if (list.Count > 0) { Bundle bundleInstantiate = list.Dequeue(); bundleInstantiate.gameObject.SetActive(true); if (onComplete != null) onComplete(assetName, bundleInstantiate); return; } } // 判断缓存 if (instance.mAssetCached.ContainsKey(assetName)) { Bundle b = (Bundle)instance.mAssetCached[assetName]; if (b != null) { if (onComplete != null) onComplete(assetName, InstantiateBundle(b)); } return; } AssetLoadRequest loadRequest = (AssetLoadRequest)FindLoadRequestByName(assetName); if (loadRequest != null) { instance.mAssetLoadRequestWaitList.Add(new AssetLoadRequestWait() { assetName = assetName, onComplete = onComplete }); return; } string abPath = instance.data.assetBundlePath[assetName]; AssetLoadRequest abLoadRequest = new AssetLoadRequest(); abLoadRequest.assetName = assetName; abLoadRequest.onComplete = onComplete; abLoadRequest.isSub = isSub; instance.mAssetLoadRequestList.Add(abLoadRequest); // 添加至资源请求list instance.StartCoroutine(instance.LoadAssetBundle(abPath, abLoadRequest)); }