public virtual void Modify(BundleData bundleData) { BundleInfo bundleInfo = bundleData.BundleInfo; string name = string.Format("{0}-{1}-{2}-{3}", bundleInfo.FullName, bundleInfo.Hash.ToString(), bundleInfo.CRC, bundleInfo.IsEncrypted ? bundleInfo.Encoding : ""); bundleInfo.Filename = BitConverter.ToString(MD5.ComputeHash(Encoding.ASCII.GetBytes(name))).Replace("-", "").ToLower(); }
public virtual void Modify(BundleData bundleData) { BundleInfo bundleInfo = bundleData.BundleInfo; if (match != null) { bundleInfo.Published = match(bundleInfo); } }
public virtual void Modify(BundleData bundleData) { BundleInfo bundleInfo = bundleData.BundleInfo; if (filter != null && !filter(bundleInfo)) { return; } var data = this.encryptor.Encrypt(bundleData.Data); bundleData.Data = data; bundleInfo.FileSize = data.Length; bundleInfo.Encoding = this.encryptor.AlgorithmName; }
public virtual BundleManifest CopyAssetBundle(BundleManifest manifest, DirectoryInfo src, DirectoryInfo dest, List <IBundleModifier> bundleModifierChain = null, IBundleFilter bundleFilter = null) { if (!src.Exists) { throw new DirectoryNotFoundException(string.Format("Not found the directory '{0}'.", src.FullName)); } try { foreach (BundleInfo bundleInfo in manifest.GetAll()) { if (bundleFilter != null && !bundleFilter.IsValid(bundleInfo)) { continue; } FileInfo srcFile = new FileInfo(System.IO.Path.Combine(src.FullName, bundleInfo.Filename).Replace(@"\", "/")); byte[] data = File.ReadAllBytes(srcFile.FullName); BundleData bundleData = new BundleData(bundleInfo, data); if (bundleModifierChain != null && bundleModifierChain.Count > 0) { foreach (IBundleModifier modifier in bundleModifierChain) { modifier.Modify(bundleData); } } FileInfo destFile = new FileInfo(System.IO.Path.Combine(dest.FullName, bundleInfo.Filename).Replace(@"\", "/")); if (destFile.Exists) { destFile.Delete(); } if (!destFile.Directory.Exists) { destFile.Directory.Create(); } File.WriteAllBytes(destFile.FullName, bundleData.Data); } return(manifest); } catch (System.Exception e) { throw new System.Exception(string.Format("Copy AssetBundles failure from {0} to {1}.", src.FullName, dest.FullName), e); } }