|
@@ -74,21 +74,21 @@ namespace VEngine.Editor.Builds
|
|
|
FinishBuild();
|
|
|
}
|
|
|
|
|
|
- public void BuildCustomBundles(string[] resRootDirNames)
|
|
|
+ public void BuildCustomBundles(string[] resRootDirNames, string setName)
|
|
|
{
|
|
|
foreach(var resRootDirName in resRootDirNames)
|
|
|
{
|
|
|
- CreateBundles(resRootDirName);
|
|
|
+ CreateBundles(resRootDirName, setName);
|
|
|
}
|
|
|
CheckAssets();
|
|
|
EditorUtility.ClearProgressBar();
|
|
|
FinishBuild();
|
|
|
}
|
|
|
|
|
|
- private void CreateBundles(string resRootDirName)
|
|
|
+ private void CreateBundles(string resRootDirName, string setName)
|
|
|
{
|
|
|
var path = Path.Combine(Application.dataPath, resRootDirName);
|
|
|
- var buildSetting = GFGEditor.BuildSetting.GetBuildSetting();
|
|
|
+ var buildSetting = GFGEditor.BuildSetting.GetBuildSetting(setName);
|
|
|
var dirBundleList = buildSetting.dirBundleList;
|
|
|
var excludeDirs = buildSetting.dirBundleList.GetRange(0, buildSetting.dirBundleList.Count);
|
|
|
excludeDirs.AddRange(EXCLUDE_DIRS);
|
|
@@ -203,11 +203,37 @@ namespace VEngine.Editor.Builds
|
|
|
Debug.LogErrorFormat("Failed to build {0}.", name);
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+ if(!string.IsNullOrEmpty(GFGGame.LauncherConfig.resKey))
|
|
|
+ {
|
|
|
+ CreateEncryptAssets(outputPath, outputPath, manifest, GFGGame.LauncherConfig.resKey);
|
|
|
+ }
|
|
|
AfterBuildBundles(bundles, manifest);
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 创建加密的AssetBundle
|
|
|
+ /// </summary>
|
|
|
+ public static void CreateEncryptAssets(string bundlePackagePath, string encryptAssetPath, AssetBundleManifest manifest, string secretKey)
|
|
|
+ {
|
|
|
+ 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(bundlePackagePath, assetBundle), FileMode.OpenOrCreate))
|
|
|
+ {
|
|
|
+ fs.SetLength(0);
|
|
|
+ fs.Write(encryptBytes, 0, encryptBytes.Length);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private string GetOriginBundle(string assetBundle)
|
|
|
{
|
|
|
var pos = assetBundle.LastIndexOf("_", StringComparison.Ordinal) + 1;
|