protected bool CreateAssetBundleAsync(string assetbundleName, bool isIndependent = false) { #if UNITY_EDITOR // EditorApplication.isPaused = true; #endif if (IsAssetBundleLoaded(assetbundleName) || webRequesting.ContainsKey(assetbundleName)) { return(false); } var creater = ResourceWebRequester.Get(); var url = AssetBundleUtility.GetAssetBundleFileUrl(assetbundleName); if (!manifest.GetAssetBundleHash(assetbundleName).isValid&& idpManifest.GetAssetBundleHash(assetbundleName).isValid) { url = AssetBundleUtility.GetIndependentAssetBundleFileUrl(assetbundleName); } creater.Init(assetbundleName, url); webRequesting.Add(assetbundleName, creater); webRequesterQueue.Enqueue(creater); // 创建器持有的引用:创建器对每个ab来说是全局唯一的 IncreaseReferenceCount(assetbundleName); return(true); }
// 本地异步请求Assetbundle资源,不计引用计数、不缓存,Creater使用后记得回收 public ResourceWebRequester RequestAssetBundleAsync(string assetbundleName) { var creater = ResourceWebRequester.Get(); var url = AssetBundleUtility.GetAssetBundleFileUrl(assetbundleName); creater.Init(assetbundleName, url, true); webRequesting.Add(assetbundleName, creater); webRequesterQueue.Enqueue(creater); return creater; }
// 本地异步请求Assetbundle资源,不计引用计数、不缓存,Creater使用后记得回收 public ResourceWebRequester RequestAssetBundleAsync(string assetbundleName) { var creater = ResourceWebRequester.Get(); var url = AssetBundleUtility.GetAssetBundleFileUrl(assetbundleName); #if UNITY_CLIENT Debug.Log("RequestAssetBundleAsync:" + url); #endif creater.Init(assetbundleName, url, true); webRequesting.Add(assetbundleName, creater); webRequesterQueue.Enqueue(creater); return(creater); }
protected bool CreateAssetBundleAsync(string assetbundleName) { if (IsAssetBundleLoaded(assetbundleName) || webRequesting.ContainsKey(assetbundleName)) { return false; } var creater = ResourceWebRequester.Get(); var url = AssetBundleUtility.GetAssetBundleFileUrl(assetbundleName); creater.Init(assetbundleName, url); webRequesting.Add(assetbundleName, creater); webRequesterQueue.Enqueue(creater); // 创建器持有的引用:创建器对每个ab来说是全局唯一的 IncreaseReferenceCount(assetbundleName); return true; }
private bool CreateAssetBundleAsync(string assetbundleName) { if (IsAssetBundleLoaded(assetbundleName) || assetbundleRequesting.ContainsKey(assetbundleName)) { return(false); } var creater = ResourceAssetBundleRequester.Get(); var url = AssetBundleUtility.GetAssetBundleFileUrl(assetbundleName); creater.Init(assetbundleName, url); assetbundleRequesting.Add(assetbundleName, creater); assetbundleRequesterQueue.Enqueue(creater); return(true); }
// 本地异步请求非Assetbundle资源,非AB(不计引用计数、不缓存),Creater使用后记得回收 public ResourceWebRequester RequestAssetFileAsync(string filePath, bool streamingAssetsOnly = true) { var creater = ResourceWebRequester.Get(); string url = null; if (streamingAssetsOnly) { url = AssetBundleUtility.GetStreamingAssetsFilePath(filePath); } else { url = AssetBundleUtility.GetAssetBundleFileUrl(filePath); } creater.Init(filePath, url, true); webRequesting.Add(filePath, creater); webRequesterQueue.Enqueue(creater); return creater; }
/// <summary> /// 加载 ab package 内包含的资源 /// </summary> public void LoadRes() { // 已经加载过了 if (_isLoaded) { return; } /// 加载 _resRef 依赖的资源 for (int i = waitingList.Count - 1; i >= 0; i--) { /// 还的解析 assetname, 靠!!! var url = AssetBundleUtility.GetAssetBundleFileUrl(waitingList[i]); var r = ResManager.LoadObject(waitingList[i], url, true); _resRefs.Add(r); } { // 对于package 来说, resRef 可能只hold bundle, object,加载不了因为 …… var url = AssetBundleUtility.GetAssetBundleFileUrl(assetbundleName); _resRef = ResManager.LoadObject(assetbundleName, url, true); } _isLoaded = true; }