private static void DispatchReqComplete(CRequest reqitem) { if (reqitem.isShared) { CountMananger.Add(reqitem.keyHashCode); CountMananger.AddDependencies(reqitem.keyHashCode); if (_instance && _instance.OnSharedComplete != null) { _instance.OnSharedComplete(reqitem); } CacheManager.SetAssetLoaded(reqitem.keyHashCode); if (reqitem.pool) { LRequestPool.Release(reqitem); } } else { if (reqitem.assetBundleRequest != null) { CacheManager.RemoveLock(reqitem.keyHashCode); } reqitem.DispatchComplete(); PopGroup(reqitem); } }
protected static void LoadAssetComplate(CRequest req) { #if HUGULA_LOADER_DEBUG Debug.LogFormat(" 6. <color=yellow>LoadAssetComplate Req(assetname={0},url={1}) frameCount{2}</color>", req.assetName, req.url, Time.frameCount); #endif if (req.isShared) { CountMananger.Add(req.keyHashCode); CountMananger.AddDependencies(req.keyHashCode); if (_instance && _instance.OnSharedComplete != null) { _instance.OnSharedComplete(req); } CacheManager.SetAssetLoaded(req.keyHashCode); if (req.pool) { LRequestPool.Release(req); } } else { if (req.assetBundleRequest != null) { CacheManager.RemoveLock(req.keyHashCode); } req.DispatchComplete(); PopGroup(req); } BeginQueue(); CheckAllComplete(); }
/// <summary> /// 加载依赖项目 /// </summary> /// <param name="req"></param> static protected int[] LoadDependencies(CRequest req) { string[] deps = assetBundleManifest.GetAllDependencies(req.assetBundleName); if (deps.Length == 0) { return(null); } string dep_url; string depAbName = ""; CRequest item; int[] hashs = new int[deps.Length]; int keyhash; for (int i = 0; i < deps.Length; i++) { depAbName = deps [i]; dep_url = RemapVariantName(depAbName); keyhash = LuaHelper.StringToHash(dep_url); hashs[i] = keyhash; if (CacheManager.Contains(keyhash)) { CountMananger.Add(keyhash); //引用数量加1 } else { item = LRequestPool.Get(); //new CRequest(dep_url); item.relativeUrl = dep_url; item.isShared = true; item.async = false; //依赖项目 string[] depds = assetBundleManifest.GetAllDependencies(item.assetBundleName); if (depds.Length > 0) { int[] hash1s = new int[depds.Length]; for (int i1 = 0; i1 < depds.Length; i1++) { depAbName = depds [i1]; dep_url = RemapVariantName(depAbName); keyhash = LuaHelper.StringToHash(dep_url); hash1s[i1] = keyhash; } item.allDependencies = hash1s; } #if HUGULA_LOADER_DEBUG Debug.LogFormat("<color=yellow> Req(assetname={0}) /r/n Begin LoadDependencies Req(assetname={1},url={2}) frameCount{3}</color>", req.assetBundleName, item.assetName, item.url, Time.frameCount); #endif item.isNormal = req.isNormal; item.uris = req.uris; AddReqToQueue(item); } } return(hashs); }
/// <summary> /// 加载依赖项目 /// </summary> /// <param name="req"></param> static protected int[] LoadDependencies(CRequest req) { string[] deps = assetBundleManifest.GetAllDependencies(req.assetBundleName); if (deps.Length == 0) { return(null); } string dep_url; string depAbName = ""; CRequest item; int[] hashs = new int[deps.Length]; int keyhash; for (int i = 0; i < deps.Length; i++) { depAbName = deps [i]; if (string.IsNullOrEmpty(depAbName)) // Dependency assetbundle name is empty unity bug? { #if UNITY_EDITOR Debug.LogWarningFormat("the request({0},{1}) Dependencies {2} is empty ", req.assetName, req.url, i); #endif hashs[i] = 0; continue; } dep_url = RemapVariantName(depAbName); keyhash = LuaHelper.StringToHash(dep_url); hashs[i] = keyhash; CacheData sharedCD = CacheManager.GetCache(keyhash); if (sharedCD != null) { CountMananger.Add(keyhash); //引用数量加1 if (!sharedCD.isAssetLoaded) { item = LRequestPool.Get(); //new CRequest(dep_url); item.relativeUrl = dep_url; item.isShared = true; item.async = false; item.isAssetBundle = true; CacheManager.SetRequestDataFromCache(req); if (_instance && _instance.OnSharedComplete != null) { _instance.OnSharedComplete(item); } LRequestPool.Release(item); } #if HUGULA_LOADER_DEBUG Debug.LogFormat(" 0.3 <color=#153AC1>Request(assetName={0}, url={1},isShared={2}) Dependencies CacheManager.Contains(url={3},sharedCD.isAssetLoaded={4}) </color>", req.assetName, req.url, req.isShared, dep_url, sharedCD.isAssetLoaded); #endif } else { item = LRequestPool.Get(); //new CRequest(dep_url); item.relativeUrl = dep_url; item.isShared = true; item.async = false; item.isAssetBundle = true; //依赖项目 string[] depds = assetBundleManifest.GetAllDependencies(item.assetBundleName); if (depds.Length > 0) { int[] hash1s = new int[depds.Length]; for (int i1 = 0; i1 < depds.Length; i1++) { depAbName = depds [i1]; dep_url = RemapVariantName(depAbName); keyhash = LuaHelper.StringToHash(dep_url); hash1s[i1] = keyhash; } item.allDependencies = hash1s; } #if HUGULA_LOADER_DEBUG Debug.LogFormat("<color=#153AC1>0.5 Request(assetname={0}) Begin Load Dependencies Req(assetname={1},url={2}) frameCount{3}</color>", req.assetName, item.assetName, item.url, Time.frameCount); #endif item.isNormal = false; item.priority = req.priority; item.uris = req.uris; AddReqToQueue(item); } } return(hashs); }