void StartLoadAssets(AssetBundleAssetLoadingInfo info) { try { var bundleName = info.BundleName; BundleInfo gBundle = ResourceMgr.Instance().GetBundle(bundleName); var bundle = info.AssetBundle; if (!bundle) { DebugUtil.LogError(string.Format("AssetBundle {0} is null", gBundle.mName)); return; } info.Requests = new List <AssetRequestInfo>(); bool shouldAsync = true; info.IsAsync = shouldAsync; bool isPreload = bundleLoadedCallbacks.ContainsKey(bundleName) || !ResourceModule.Instance.UseAssetBundleLoadFromFile; #if DEBUG_BUNDLE_CACHE ResourceMgr.Instance().SampleLoadEvent(bundleName, 5); #endif var cb = cache[bundleName]; foreach (string str in gBundle.Files) { AssetRequestInfo ar = null; bool isPending = assetLoadedCallbacks.ContainsKey(str); bool canContinue = true; if (cb != null) { var a = cb[str]; if (a != null && a.AssetValid) { if (isPending) { ar = new AssetRequestInfo(); ar.AssetName = str; ar.Asset = a.Asset; info.Requests.Add(ar); } continue; } else { canContinue = false; } } else { canContinue = false; } isPending = isPending || isPreload; if (!isPending && canContinue) { continue; } ar = new AssetRequestInfo(); ar.AssetName = str; //只加载请求中的资源 if (isPending) { bool isSprite = str.IndexOf('.') < 0; if (shouldAsync) { ar.Request = isSprite ? bundle.LoadAssetAsync <Sprite>(str) : bundle.LoadAssetAsync(str); } else { ar.Asset = isSprite ? bundle.LoadAsset <Sprite>(str) : bundle.LoadAsset(str); } } info.Requests.Add(ar); } assetLoading.Add(info); } catch { DebugUtil.LogError("Cannot load assetbundle:" + info.BundleName); } }