public void Update(float deltaTime) { if (mCallBackTable.Count > 0) { keys.Clear(); foreach (string key in mCallBackTable.Keys) { keys.Add(key); } foreach (string key in keys) { if (!mCallBackTable.ContainsKey(key)) { continue; } AssetBundleLoadedCallBack cb = mCallBackTable[key]; if (DownLoader.Instance.Loaded(key)) { mCallBackTable.Remove(key); DownLoadUnit dlu = DownLoader.Instance.Fetch(key); if (dlu != null && dlu.GetWWW().error == null) { bool suc = DownLoadResultFetcher.Instance.WriteAssetbundle(dlu, key); cb(suc); dlu.GetWWW().assetBundle.Unload(true); } else { cb(false); } dlu.ReleaseRes(); } } } }
public void PreLoadAssetBundle(string path, AssetBundleLoadedCallBack resLoaded, bool forceLoadFromSource = false) { if (string.IsNullOrEmpty(path)) { return; } string filePath = GameInfo.FilePath + "AssetBundles_" + GameInfo.RegionString + "/" + path; Debug.Log("load filePath:" + filePath); if (File.Exists(filePath)) { AssetBundle ab = AssetBundle.LoadFromFile(filePath); if (ab != null) { if (resLoaded != null) { resLoaded(true); } return; } } if (!mCallBackTable.ContainsKey(path)) { DownLoader.Instance.Request(path, ResourceType.RT_ASSETBUNDLE, ThreadPriority.Normal); } if (resLoaded != null) { mCallBackTable[path] = resLoaded; } ProcessManager.Add(Instance); }