private void LoadMainfestFile(string category) { var path = AssetVersionUtility.GetAssetFilePath(StringUtil.Contact(category, "_assetbundle")); var assetBundle = AssetBundle.LoadFromFile(path); if (assetBundle == null) { DebugEx.LogError("AssetBundleManifest的包文件为空或者加载出错."); return; } var manifest = assetBundle.LoadAsset <AssetBundleManifest>(AssetPath.AssetDependentFileAssetName); if (manifest == null) { DebugEx.LogError("AssetBundleManifest文件为空或者加载出错."); return; } var assetBundleNames = manifest.GetAllAssetBundles(); foreach (var assetBundleName in assetBundleNames) { var dependenices = manifest.GetAllDependencies(assetBundleName); var hash = manifest.GetAssetBundleHash(assetBundleName); var assetBundleInfo = new AssetBundleInfo(assetBundleName, hash, dependenices); this.m_AssetBundleInfoList.Add(assetBundleInfo); } assetBundle.Unload(true); assetBundle = null; }
public bool CheckLocalFileValid() { if (this.extension == ".manifest" || this.extension == ".bytes" || this.extension == ".txt" || this.extension == ".dll") { var path = StringUtil.Contact(AssetPath.ExternalStorePath, this.m_RelativePath); var fileInfo = new FileInfo(path); if (!fileInfo.Exists || fileInfo.Length != this.size || this.md5 != FileExtension.GetMD5HashFromFile(path)) { return(false); } } else if (string.IsNullOrEmpty(this.extension) || this.extension.Length == 0) { var path = StringUtil.Contact(AssetPath.ExternalStorePath, this.m_RelativePath); var fileInfo = new FileInfo(path); var manifestAssetVersion = AssetVersionUtility.GetAssetVersion(StringUtil.Contact(this.m_RelativePath, ".manifest")); if (!fileInfo.Exists || fileInfo.Length != this.size || manifestAssetVersion == null || !manifestAssetVersion.CheckLocalFileValid()) { return(false); } } else { var path = StringUtil.Contact(AssetPath.ExternalStorePath, this.m_RelativePath); var fileInfo = new FileInfo(path); if (!fileInfo.Exists || fileInfo.Length != this.size) { return(false); } } return(true); }
private void SyncLoadAssetBundle(string assetBundleName) { if (ExistAssetBundle(assetBundleName)) { return; } var assetBundleInfo = GetAssetBundleInfo(assetBundleName); LoadAssetBundleDependenice(assetBundleInfo.dependentBundles); var path = AssetVersionUtility.GetAssetFilePath(assetBundleName); var assetBundle = AssetBundle.LoadFromFile(path); CacheAssetBundle(assetBundleName, assetBundle); }