|
@@ -234,24 +234,24 @@ namespace VEngine.Editor.Builds
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 创建加密的AssetBundle
|
|
/// 创建加密的AssetBundle
|
|
/// </summary>
|
|
/// </summary>
|
|
- public static void CreateEncryptAssets(string bundlePackagePath, string encryptAssetPath, AssetBundleManifest manifest, string secretKey)
|
|
|
|
- {
|
|
|
|
- if (!Directory.Exists(encryptAssetPath))
|
|
|
|
- {
|
|
|
|
- Directory.CreateDirectory(encryptAssetPath);
|
|
|
|
- }
|
|
|
|
- string[] assetBundles = manifest.GetAllAssetBundles();
|
|
|
|
- foreach (string assetBundle in assetBundles)
|
|
|
|
- {
|
|
|
|
- string bundlePath = Path.Combine(bundlePackagePath, assetBundle);
|
|
|
|
- byte[] encryptBytes = EncryptHelper.CreateEncryptData(bundlePath, secretKey);
|
|
|
|
- using (FileStream fs = new FileStream(Path.Combine(encryptAssetPath, assetBundle), FileMode.OpenOrCreate))
|
|
|
|
- {
|
|
|
|
- fs.SetLength(0);
|
|
|
|
- fs.Write(encryptBytes, 0, encryptBytes.Length);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ //public static void CreateEncryptAssets(string bundlePackagePath, string encryptAssetPath, AssetBundleManifest manifest, string secretKey)
|
|
|
|
+ //{
|
|
|
|
+ // if (!Directory.Exists(encryptAssetPath))
|
|
|
|
+ // {
|
|
|
|
+ // Directory.CreateDirectory(encryptAssetPath);
|
|
|
|
+ // }
|
|
|
|
+ // string[] assetBundles = manifest.GetAllAssetBundles();
|
|
|
|
+ // foreach (string assetBundle in assetBundles)
|
|
|
|
+ // {
|
|
|
|
+ // string bundlePath = Path.Combine(bundlePackagePath, assetBundle);
|
|
|
|
+ // byte[] encryptBytes = EncryptHelper.CreateEncryptData(bundlePath, secretKey);
|
|
|
|
+ // using (FileStream fs = new FileStream(Path.Combine(encryptAssetPath, assetBundle), FileMode.OpenOrCreate))
|
|
|
|
+ // {
|
|
|
|
+ // fs.SetLength(0);
|
|
|
|
+ // fs.Write(encryptBytes, 0, encryptBytes.Length);
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 创建加密的AssetBundle
|
|
/// 创建加密的AssetBundle
|
|
@@ -324,6 +324,7 @@ namespace VEngine.Editor.Builds
|
|
var newFiles = new List<string>();
|
|
var newFiles = new List<string>();
|
|
var newSize = 0L;
|
|
var newSize = 0L;
|
|
foreach (var bundle in bundles)
|
|
foreach (var bundle in bundles)
|
|
|
|
+ {
|
|
if (!getBundles.TryGetValue(bundle.name, out var value) ||
|
|
if (!getBundles.TryGetValue(bundle.name, out var value) ||
|
|
value.nameWithAppendHash != bundle.nameWithAppendHash)
|
|
value.nameWithAppendHash != bundle.nameWithAppendHash)
|
|
{
|
|
{
|
|
@@ -333,17 +334,19 @@ namespace VEngine.Editor.Builds
|
|
string buildPath = Settings.PlatformBuildPath;
|
|
string buildPath = Settings.PlatformBuildPath;
|
|
CreateEncryptAsset(Settings.UnityBuildPath, buildPath, bundle.nameWithAppendHash, GFGGame.LauncherConfig.resKey);
|
|
CreateEncryptAsset(Settings.UnityBuildPath, buildPath, bundle.nameWithAppendHash, GFGGame.LauncherConfig.resKey);
|
|
}
|
|
}
|
|
- var file = Settings.GetBuildPath(bundle.nameWithAppendHash);
|
|
|
|
- if (File.Exists(file))
|
|
|
|
- using (var stream = File.OpenRead(file))
|
|
|
|
- {
|
|
|
|
- bundle.size = stream.Length;
|
|
|
|
- bundle.crc = Utility.ComputeCRC32(stream);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- Debug.LogErrorFormat("File not found: {0}", file);
|
|
|
|
- newSize += bundle.size;
|
|
|
|
}
|
|
}
|
|
|
|
+ var file = Settings.GetBuildPath(bundle.nameWithAppendHash);
|
|
|
|
+ if (File.Exists(file))
|
|
|
|
+ using (var stream = File.OpenRead(file))
|
|
|
|
+ {
|
|
|
|
+ bundle.size = stream.Length;
|
|
|
|
+ bundle.crc = Utility.ComputeCRC32(stream);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ Debug.LogErrorFormat("File not found: {0}", file);
|
|
|
|
+ newSize += bundle.size;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
manifest.bundles = bundles;
|
|
manifest.bundles = bundles;
|
|
var newFilesSize = Utility.FormatBytes(newSize);
|
|
var newFilesSize = Utility.FormatBytes(newSize);
|