|
@@ -222,11 +222,11 @@ namespace VEngine.Editor.Builds
|
|
|
Debug.LogErrorFormat("Failed to build {0}.", name);
|
|
|
return;
|
|
|
}
|
|
|
- if (!string.IsNullOrEmpty(GFGGame.LauncherConfig.resKey))
|
|
|
- {
|
|
|
- string buildPath = Settings.PlatformBuildPath;
|
|
|
- CreateEncryptAssets(unityBuildPath, buildPath, manifest, GFGGame.LauncherConfig.resKey);
|
|
|
- }
|
|
|
+ //if (!string.IsNullOrEmpty(GFGGame.LauncherConfig.resKey))
|
|
|
+ //{
|
|
|
+ // string buildPath = Settings.PlatformBuildPath;
|
|
|
+ // CreateEncryptAssets(unityBuildPath, buildPath, manifest, GFGGame.LauncherConfig.resKey);
|
|
|
+ //}
|
|
|
AfterBuildBundles(bundles, manifest);
|
|
|
}
|
|
|
|
|
@@ -236,15 +236,15 @@ namespace VEngine.Editor.Builds
|
|
|
/// </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);
|
|
|
- if (!Directory.Exists(encryptAssetPath))
|
|
|
- {
|
|
|
- Directory.CreateDirectory(encryptAssetPath);
|
|
|
- }
|
|
|
using (FileStream fs = new FileStream(Path.Combine(encryptAssetPath, assetBundle), FileMode.OpenOrCreate))
|
|
|
{
|
|
|
fs.SetLength(0);
|
|
@@ -253,6 +253,23 @@ namespace VEngine.Editor.Builds
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 创建加密的AssetBundle
|
|
|
+ /// </summary>
|
|
|
+ public static void CreateEncryptAsset(string unityBundlesPath, string bundlesPath, string unityBundle, string secretKey)
|
|
|
+ {
|
|
|
+ if (!Directory.Exists(bundlesPath))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(bundlesPath);
|
|
|
+ }
|
|
|
+ string unityBundlePath = Path.Combine(unityBundlesPath, unityBundle);
|
|
|
+ byte[] encryptBytes = EncryptHelper.CreateEncryptData(unityBundlePath, secretKey);
|
|
|
+ using (FileStream fs = new FileStream(Path.Combine(bundlesPath, unityBundle), FileMode.OpenOrCreate))
|
|
|
+ {
|
|
|
+ fs.SetLength(0);
|
|
|
+ fs.Write(encryptBytes, 0, encryptBytes.Length);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
private string GetOriginBundle(string assetBundle)
|
|
|
{
|
|
@@ -286,15 +303,7 @@ namespace VEngine.Editor.Builds
|
|
|
{
|
|
|
manifestBundle.nameWithAppendHash = assetBundle;
|
|
|
manifestBundle.dependencies = Array.ConvertAll(dependencies, input => nameWithBundles[input].id);
|
|
|
- var file = Settings.GetBuildPath(assetBundle);
|
|
|
- if (File.Exists(file))
|
|
|
- using (var stream = File.OpenRead(file))
|
|
|
- {
|
|
|
- manifestBundle.size = stream.Length;
|
|
|
- manifestBundle.crc = Utility.ComputeCRC32(stream);
|
|
|
- }
|
|
|
- else
|
|
|
- Debug.LogErrorFormat("File not found: {0}", file);
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -319,6 +328,20 @@ namespace VEngine.Editor.Builds
|
|
|
value.nameWithAppendHash != bundle.nameWithAppendHash)
|
|
|
{
|
|
|
newFiles.Add(bundle.nameWithAppendHash);
|
|
|
+ if (!string.IsNullOrEmpty(GFGGame.LauncherConfig.resKey))
|
|
|
+ {
|
|
|
+ string buildPath = Settings.PlatformBuildPath;
|
|
|
+ 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;
|
|
|
}
|
|
|
|