/// <summary> /// real load assetbundle /// </summary> /// <param name="req"></param> /// <returns></returns> static protected AssetBundleDownloadOperation LoadAssetBundleInternal(CRequest req) { AssetBundleDownloadOperation abDownloadOp = null; if (!downloadingBundles.TryGetValue(req.key, out abDownloadOp)) { req.url = GetAssetBundleDownloadingURL(req.vUrl); // set full url if (req.url.StartsWith(Common.HTTP_STRING)) //load assetbunlde { abDownloadOp = AssetBundleDownloadFromWebOperation.Get(); } else { abDownloadOp = AssetBundleDownloadFromDiskOperation.Get(); } abDownloadOp.SetRequest(req); downloadingBundles.Add(req.key, abDownloadOp); CacheData cached = null; CacheManager.CreateOrGetCache(req.keyHashCode, out cached);//cache data inProgressBundleOperations.Add(abDownloadOp); abDownloadOp.BeginDownload(); #if HUGULA_LOADER_DEBUG HugulaDebug.FilterLogFormat(req.key, "<color=#10f010>1.2 LoadAssetBundleInternal Request(key={0},isShared={1},assetname={2},dependencies.count={4})keyHashCode{3}, frameCount{5}</color>", req.key, req.isShared, req.assetName, req.keyHashCode, req.dependencies == null ? 0 : req.dependencies.Length, Time.frameCount); #endif } else if (req.isShared) { req.ReleaseToPool(); } return(abDownloadOp); }
/// <summary> /// finish assetbundle /// </summary> /// <param name="operation"></param> static void ProcessFinishedBundleOperation(AssetBundleDownloadOperation operation) { #if HUGULA_PROFILER_DEBUG Profiler.BeginSample(string.Format("ResourcesLoader.ProcessFinishedBundleOperation CRequest({0},shared={1})", operation.cRequest.assetName, operation.cRequest.isShared)); #endif var req = operation.cRequest; bool isError = operation.assetBundle == null; var ab = operation.assetBundle; AssetBundleDownloadOperation download = operation; if (isError && UriGroup.CheckAndSetNextUriGroup(req)) { #if HUGULA_LOADER_DEBUG HugulaDebug.FilterLogFormat(req.key, "<color=#10f010>1.9 ProcessFinishedBundleOperation AssetBundle re Loaded Request(url={0},assetname={1},dependencies.count={3},keyHashCode{2}),isError={4} frameCount{5}</color>", req.url, req.assetName, req.keyHashCode, req.dependencies == null ? 0 : req.dependencies.Length, isError, Time.frameCount); #endif //loop load a assetbundle maybe cause a crash : signal 6 (SIGABRT), code -6 (?), fault addr -------- inProgressBundleOperations.Add(download); download.Reset(); download.SetRequest(req); download.BeginDownload(); //retry } else { if (!isError) { CacheManager.AddSourceCacheDataFromWWW(ab, req); } else { #if UNITY_EDITOR Debug.LogWarning(operation.error); #endif CacheManager.AddErrorSourceCacheDataFromReq(req); } #if HUGULA_LOADER_DEBUG HugulaDebug.FilterLogFormat(req.key, "<color=#10f010>1.9 ProcessFinishedBundleOperation AssetBundle Loaded Request(url={0},assetname={1},dependencies.count={3},keyHashCode{2}),isError={4} frameCount{5}</color>", req.url, req.assetName, req.keyHashCode, req.dependencies == null ? 0 : req.dependencies.Length, isError, Time.frameCount); #endif //begin load asset InsertAssetBundleLoadAssetOperation(download); downloadingBundles.Remove(req.key); download.ReleaseToPool(); if (isError) { CallOnAssetBundleErr(req); } else { CallOnAssetBundleComplete(req, ab); } if (req.isShared) { req.ReleaseToPool(); } } #if HUGULA_PROFILER_DEBUG Profiler.EndSample(); #endif }