public AsyncOperationHandle DownloadDependenciesAsync(IList <object> keys, Addressables.MergeMode mode) { if (!InitializationOperation.IsDone) { return(ResourceManager.CreateChainOperation <IList <IAssetBundleResource> >(InitializationOperation, op => DownloadDependenciesAsync(keys, mode).Convert <IList <IAssetBundleResource> >())); } IList <IResourceLocation> locations; if (!GetResourceLocations(keys, typeof(object), mode, out locations)) { return(ResourceManager.CreateCompletedOperation <IList <IAssetBundleResource> >(null, new InvalidKeyException(keys).Message)); } var locHash = new HashSet <IResourceLocation>(); foreach (var loc in locations) { if (loc.HasDependencies) { foreach (var dep in loc.Dependencies) { locHash.Add(dep); } } } return(LoadAssetsAsync <IAssetBundleResource>(new List <IResourceLocation>(locHash), null)); }
//下载更新资源 public ETTask <Dictionary <string, string> > CheckUpdateContent(List <string> keys, int iMergeMode) { Addressables.MergeMode mergeMode = (Addressables.MergeMode)iMergeMode; ETTask <Dictionary <string, string> > result = ETTask <Dictionary <string, string> > .Create(); var handle = Addressables.LoadResourceLocationsAsync(keys, mergeMode); handle.Completed += (res) => { if (handle.Status == AsyncOperationStatus.Succeeded) { if (handle.Result != null && handle.Result.Count > 0) { var downlocations = handle.Result; string bundleName3; string path; AssetBundleRequestOptions data; var needLoadInfo = new Dictionary <string, string>(); if (downlocations != null && downlocations.Count > 0) { foreach (var item in downlocations) { if (item.HasDependencies) { foreach (var dep in item.Dependencies) { bundleName3 = Path.GetFileName(dep.InternalId); if (dep.Data != null) { data = dep.Data as AssetBundleRequestOptions; path = AssetBundleMgr.GetInstance().TransformAssetBundleLocation(dep.InternalId, bundleName3, data.Hash); if (UnityEngine.ResourceManagement.Util.ResourceManagerConfig.ShouldPathUseWebRequest(path)) { needLoadInfo[bundleName3] = data.Hash; } } } } } } result.SetResult(needLoadInfo); } else { result.SetResult(null); } } else { result.SetResult(null); } Addressables.Release(handle); }; return(result); }
public void Load(IEnumerable <string> keys, Addressables.MergeMode mergeMode = Addressables.MergeMode.Intersection) { if (_handle != null || _isDisposed) { return; } _handle = Addressables.LoadAssetsAsync <object>(keys.Cast <object>().ToList(), null, mergeMode); if (_handle.Value.IsDone) { OnComplete(_handle.Value); } else { _handle.Value.Completed += OnComplete; } }
public static async Task <List <string> > DestinationLableAddress(IList <object> keys, Addressables.MergeMode mergeMode = Addressables.MergeMode.Intersection) { var handle = Addressables.LoadResourceLocationsAsync(keys, mergeMode); await handle.Task; IList <IResourceLocation> resourceLocations = handle.Result; List <string> addressList = new List <string>(); for (int i = 0; i < resourceLocations.Count; i++) { addressList.Add(resourceLocations[i].PrimaryKey); } return(addressList); }
public IAsyncOperation <IList <TObject> > LoadAssets <TObject>(IList <object> keys, Action <IAsyncOperation <TObject> > callback, Addressables.MergeMode mode = Addressables.MergeMode.None) where TObject : class { return(Addressables.LoadAssets <TObject>(keys, callback, mode)); }
/// <summary> /// Loads all assets from a given list into memory /// </summary> /// <typeparam name="T"></typeparam> /// <param name="labels">List of labels to load</param> /// <param name="callback">Callback to execute after loading</param> /// <param name="mergeMode">Assets merge mode. For more information, visit https://docs.unity3d.com/Packages/[email protected]/api/UnityEngine.AddressableAssets.Addressables.MergeMode.html?q=mergemode</param> /// <returns>Returns a list with elements of type T.</returns> public async Task <List <T> > LoadFromList <T>(List <string> labels, Action <T> callback = null, Addressables.MergeMode mergeMode = Addressables.MergeMode.None) where T : class { List <object> labelsAsObjects = labels.Cast <object>().ToList(); return(await Addressables.LoadAssetsAsync <T>(labelsAsObjects, callback, mergeMode) as List <T>); }
public MultiGameObjectLoadingHandle(IList <string> keys, Addressables.MergeMode mergeMode) : base(keys, mergeMode) { }
public MultiComponentLoadingHandle(IList <string> keys, Addressables.MergeMode mergeMode) : base(keys, mergeMode) { }