protected static bool LoadAssetBundleInternal(string assetBundleName, int dlcType, bool isLoadingAssetBundleManifest = false) { LoadedAssetBundle bundle = null; if (loadedAssetBundleDic.TryGetValue(assetBundleName, out bundle) && bundle != null) { bundle.referencedCount++; return(true); } if (downloadingWWWDic.ContainsKey(assetBundleName)) { return(true); } if (isLoadingAssetBundleManifest) { if (!File.Exists(PathUtility.Combine(false, AssetBundlePathUtility.GetCacheAssetpath(false), assetBundleName))) { isInitialized = true; return(false); } } string dlcUrl = PathUtility.Combine(false, AssetBundlePathUtility.GetCacheAssetpath(true), assetBundleName); WWW download = new WWW(dlcUrl); downloadingWWWDic.Add(assetBundleName, download); return(false); }
public static bool IsDlcAssetbundleExist(string assetBundleName) { string dlcFileUrl = PathUtility.Combine(false, AssetBundlePathUtility.GetCacheAssetpath(false), assetBundleName); if (File.Exists(dlcFileUrl)) { return(true); } return(false); }
public static Object LoadAssetSync(string assetBundleName, string assetName = "") { if ((!assetBundleManifest) || (!Instance) || (!isInitialized)) { return(null); } LoadedAssetBundle bundle = null; if (loadedAssetBundleDic.TryGetValue(assetBundleName, out bundle) && (bundle != null)) { bundle.referencedCount++; Object cacheObj = bundle.mainAssetObj; return(cacheObj); } string[] dependencies = assetBundleManifest.GetAllDependencies(assetBundleName); for (int i = 0; i < dependencies.Length; i++) { dependencies[i] = RemapVariantName(dependencies[i]); } if (!dependencyDic.ContainsKey(assetBundleName)) { dependencyDic.Add(assetBundleName, dependencies); } foreach (var dependency in dependencies) { LoadAssetSync(dependency); } string dlcFileUrl = PathUtility.Combine(false, AssetBundlePathUtility.GetCacheAssetpath(false), assetBundleName); if (!File.Exists(dlcFileUrl)) { return(null); } AssetBundle mainAb = AssetBundle.LoadFromFile(dlcFileUrl); if (mainAb == null) { return(null); } Object[] loadedObjs = mainAb.LoadAllAssets(); loadedAssetBundleDic.Add(assetBundleName, new LoadedAssetBundle(mainAb, loadedObjs.Length == 0 ? null : loadedObjs[0])); if (string.IsNullOrEmpty(assetName)) { return(loadedObjs.Length == 0 ? null : loadedObjs[0]); } else { for (int i = 0; i < loadedObjs.Length; i++) { if (loadedObjs[i].name == assetName) { return(loadedObjs[i]); } } return(null); } }