public void Setup() { _is_current_loader = new List <AssetBundleInfo>(); _asset_bundles = new Dictionary <string, AssetBundleInfo>(); _dependency = new AssetDependency(); string assetPath = AssetsCommon.LocalAssetPath + "/" + AssetsCommon.GetPlatform(); if (!File.Exists(assetPath)) { return; } _main = AssetBundle.LoadFromFile(assetPath); _manifest = _main.LoadAsset <AssetBundleManifest>("AssetBundleManifest"); string[] assetBundles = _manifest.GetAllAssetBundles(); for (int i = 0; i < assetBundles.Length; i++) { string assetBundleName = assetBundles[i].ToLower(); _asset_bundles.Add(assetBundleName, new AssetBundleInfo(assetBundleName)); string[] dependencies = _manifest.GetAllDependencies(assetBundleName); _dependency.Add(assetBundleName, dependencies); } _main.Unload(false); }
public static void AddHttpHeader( HttpWebRequest webRequest, eDownLoadType downLoadType, string version) { int versionNumber = 0; if (version != string.Empty) { string[] versionContext = version.Split('.'); if (downLoadType == eDownLoadType.ZipFile) { versionNumber = System.Convert.ToInt32(versionContext[0]); } else if (downLoadType == eDownLoadType.FileManifest) { versionNumber = System.Convert.ToInt32(versionContext[1]); } } // DownLoadType webRequest.Headers.Add("DType", string.Format("{0}={1}", DownloaderConstant.DOWNLOAD_TYPE, downLoadType)); // DownLoadSpeed webRequest.Headers.Add("DLSpeed", string.Format("{0}={1}", DownloaderConstant.DOWNLOAD_SPEED, DownloaderConstant.DownLoadSpeed)); // Version webRequest.Headers.Add("Version", string.Format("{0}={1}", "Version", versionNumber)); // OsType ePlatformType osType = AssetsCommon.GetPlatform(); webRequest.Headers.Add("PlatformType", string.Format("{0}={1}", "OsType", osType)); }
public void Save(PackageType packageType) { // 写入版本 _local_version = new VersionInfo(); _local_version.Version = UnpackCommon.GetSettingInfo().Version; _local_version.OsType = UnpackCommon.Target.ToString(); _local_version.CurrentTime = System.DateTime.Now.ToString(); _local_version.Type = packageType.ToString(); //默认散包 // 写入assetbundlemanifest string unpackPath = UnpackPath.Get(); string mainAssetBundleName = string.Format("{0}/{1}", unpackPath, UnpackCommon.GetOsType()); string mainManifestName = string.Format("{0}/{1}.manifest", unpackPath, UnpackCommon.GetOsType()); long mainAssetBundleLength = 0; long mainManifestLength = 0; string mainABMD5 = string.Empty; string mainManifestMD5 = string.Empty; if (File.Exists(mainAssetBundleName)) { using (FileStream fs = File.Open(mainAssetBundleName, FileMode.Open)) { mainAssetBundleLength = fs.Length; mainABMD5 = FileUtils.GetFileMD5ByStream(fs); fs.Close(); } } if (File.Exists(mainManifestName)) { using (FileStream fs = File.Open(mainManifestName, FileMode.Open)) { mainManifestLength = fs.Length; mainManifestMD5 = FileUtils.GetFileMD5ByStream(fs); fs.Close(); } } string fileName = AssetsCommon.GetPlatformFolderName(AssetsCommon.GetPlatform()); _local_version.AssetBundleManifestNames = new string[2]; _local_version.AssetBundleManifestLengths = new string[2]; _local_version.AssetBundleManifestMD5s = new string[2]; _local_version.AssetBundleManifestNames[0] = fileName; _local_version.AssetBundleManifestNames[1] = string.Format("{0}.manifest", fileName); _local_version.AssetBundleManifestLengths[0] = mainAssetBundleLength.ToString(); _local_version.AssetBundleManifestLengths[1] = mainManifestLength.ToString(); _local_version.AssetBundleManifestMD5s[0] = mainABMD5; _local_version.AssetBundleManifestMD5s[1] = mainManifestMD5; string jsonStr = JsonUtility.ToJson(_local_version); string versionPath = AssetBundleServerPath.FileManifest.GetVersionFileName(UnpackCommon.DefaultABPath); if (File.Exists(versionPath)) { File.Delete(versionPath); } using (FileStream stream = File.Create(versionPath)) { byte[] bytes = Encoding.Default.GetBytes(jsonStr); stream.Write(bytes, 0, bytes.Length); stream.Close(); } bool hasVersion = false; for (int i = 0; i < _all_version_number.Count; i++) { if (_all_version_number[i] == _local_version.Version) { hasVersion = true; break; } } if (!hasVersion) { _all_version_number.Add(_local_version.Version); } string versionListPath = AssetBundleServerPath.FileManifest.GetVersionListFileName(UnpackCommon.GetOsType()); if (File.Exists(versionListPath)) { File.Delete(versionListPath); } using (FileStream fs = File.Create(versionListPath)) { string context = string.Empty; for (int i = 0; i < _all_version_number.Count; i++) { if (i == _all_version_number.Count - 1) { context += _all_version_number[i]; } else { context += _all_version_number[i] + "\n"; } } byte[] bytes = System.Text.Encoding.Default.GetBytes(context); fs.Write(bytes, 0, bytes.Length); fs.Close(); } }
public override string GetURL() { ABPathInfo pathInfo = new ABPathInfo(AssetsCommon.GetPlatform(), version); return(AssetBundleServerPath.FileManifestURL.GetABAssetInfoURL(pathInfo)); }
public string GetURL() { return(AssetBundleServerPath.FileManifestURL.GetVersionListURL(AssetsCommon.GetPlatform())); }
public string GetURL() { return(AssetBundleServerPath.ABCacheURL.GetAssetBundleFileName(AssetsCommon.GetPlatform(), assetName)); }
public string GetURL() { ABPathInfo pathInfo = new ABPathInfo(AssetsCommon.GetPlatform(), version); return(AssetBundleServerPath.FenBaoURL.GetPackageFileName(pathInfo, assetName)); }