guodong %!s(int64=3) %!d(string=hai) anos
pai
achega
9c48cbf290

+ 15 - 9
GameClient/Assets/Editor/Xasset/Builds/BuildTask.cs

@@ -109,7 +109,7 @@ namespace VEngine.Editor.Builds
                     bundle = bundle.Substring(0, i);
                     bundle = bundle.ToLower();
 
-
+                    //以文件名标识分组
                     for (int j = 0; j < buildSetting.dirTypeList.Count; j++)
                     {
                         string str = buildSetting.dirTypeList[j];
@@ -127,6 +127,7 @@ namespace VEngine.Editor.Builds
                 }
 
             });
+            //以子文件夹为单位分组
             foreach (var dir in dirBundleList)
             {
                 var dirPath = Path.Combine(Environment.CurrentDirectory, dir);
@@ -165,6 +166,7 @@ namespace VEngine.Editor.Builds
             for (var i = 0; i < bundledAssets.Count; i++)
             {
                 var asset = bundledAssets[i];
+                //去重
                 if (!pathWithAssets.TryGetValue(asset.path, out var ba))
                 {
                     pathWithAssets[asset.path] = asset;
@@ -183,6 +185,7 @@ namespace VEngine.Editor.Builds
         {
             var bundles = new List<ManifestBundle>();
             var dictionary = new Dictionary<string, List<string>>();
+            //分组
             foreach (var asset in bundledAssets)
             {
                 if (!dictionary.TryGetValue(asset.bundle, out var assets))
@@ -199,9 +202,13 @@ namespace VEngine.Editor.Builds
                 assets.Add(asset.path);
             }
 
-            var outputPath = Settings.PlatformBuildPath;
+            var unityBuildPath = Settings.PlatformBuildPath;
+            if (!string.IsNullOrEmpty(GFGGame.LauncherConfig.resKey))
+            {
+                unityBuildPath = Settings.UnityBuildPath;
+            }
             if (bundles.Count <= 0) return;
-            var manifest = BuildPipeline.BuildAssetBundles(outputPath, bundles.ConvertAll(bundle =>
+            var manifest = BuildPipeline.BuildAssetBundles(unityBuildPath, bundles.ConvertAll(bundle =>
                     new AssetBundleBuild
                     {
                         assetNames = bundle.assets.ToArray(),
@@ -217,7 +224,8 @@ namespace VEngine.Editor.Builds
             }
             if (!string.IsNullOrEmpty(GFGGame.LauncherConfig.resKey))
             {
-                CreateEncryptAssets(outputPath, outputPath, manifest, GFGGame.LauncherConfig.resKey);
+                string buildPath = Settings.PlatformBuildPath;
+                CreateEncryptAssets(unityBuildPath, buildPath, manifest, GFGGame.LauncherConfig.resKey);
             }
             AfterBuildBundles(bundles, manifest);
         }
@@ -237,7 +245,7 @@ namespace VEngine.Editor.Builds
                 {
                     Directory.CreateDirectory(encryptAssetPath);
                 }
-                using (FileStream fs = new FileStream(Path.Combine(bundlePackagePath, assetBundle), FileMode.OpenOrCreate))
+                using (FileStream fs = new FileStream(Path.Combine(encryptAssetPath, assetBundle), FileMode.OpenOrCreate))
                 {
                     fs.SetLength(0);
                     fs.Write(encryptBytes, 0, encryptBytes.Length);
@@ -273,13 +281,11 @@ namespace VEngine.Editor.Builds
                 foreach (var assetBundle in assetBundles)
                 {
                     var originBundle = GetOriginBundle(assetBundle);
-                    var dependencies =
-                        Array.ConvertAll(manifest.GetAllDependencies(assetBundle), GetOriginBundle);
+                    var dependencies = Array.ConvertAll(manifest.GetAllDependencies(assetBundle), GetOriginBundle);
                     if (nameWithBundles.TryGetValue(originBundle, out var manifestBundle))
                     {
                         manifestBundle.nameWithAppendHash = assetBundle;
-                        manifestBundle.dependencies =
-                            Array.ConvertAll(dependencies, input => nameWithBundles[input].id);
+                        manifestBundle.dependencies = Array.ConvertAll(dependencies, input => nameWithBundles[input].id);
                         var file = Settings.GetBuildPath(assetBundle);
                         if (File.Exists(file))
                             using (var stream = File.OpenRead(file))

+ 11 - 0
GameClient/Assets/Editor/Xasset/Builds/Settings.cs

@@ -38,6 +38,17 @@ namespace VEngine.Editor.Builds
             }
         }
 
+        public static string UnityBuildPath
+        {
+            get
+            {
+                var dir = Utility.UnityBuildFolder + $"/{GetPlatformName()}";
+                if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
+
+                return dir;
+            }
+        }
+
         public static string BuildPlayerDataPath =>
             string.Format("{0}/{1}", Application.streamingAssetsPath, Utility.buildPath);
 

+ 2 - 0
GameClient/Assets/ThirdParty/Xasset/Runtime/Utilitys/Utility.cs

@@ -6,6 +6,8 @@ namespace VEngine
     public static class Utility
     {
         public static string buildPath = "Bundles";
+        //加密的资源所在的和普通资源同级路径的文件夹名称
+        public static string UnityBuildFolder = "UnityBuildle";
 
         public const string unsupportedPlatform = "Unsupported";