Pārlūkot izejas kodu

修改打包代码

大爷 2 gadi atpakaļ
vecāks
revīzija
bf8fd271fe

+ 1 - 1
Unity/Assets/AssetBundleCollectorSetting.asset

@@ -23,7 +23,7 @@ MonoBehaviour:
     Collectors:
     - CollectPath: Assets/Res/CodeDll
       CollectorType: 0
-      AddressRuleName: AddressByGroupAndFileName
+      AddressRuleName: AddressByFileName
       PackRuleName: PackRawFile
       FilterRuleName: CollectAll
       AssetTags: 

+ 7 - 7
Unity/Assets/Resources/HotUpdateAssemblyManifest.asset

@@ -21,10 +21,10 @@ MonoBehaviour:
   - Sirenix.Serialization.dll
   - UniTask.dll
   DLLNameList_ForABLoad:
-  - Code_System.dll
-  - Code_Unity.Core.dll
-  - Code_Unity.ThirdParty.dll
-  - Code_mscorlib.dll
-  - Code_System.Core.dll
-  - Code_Sirenix.Serialization.dll
-  - Code_UniTask.dll
+  - System.dll.bytes
+  - Unity.Core.dll.bytes
+  - Unity.ThirdParty.dll.bytes
+  - mscorlib.dll.bytes
+  - System.Core.dll.bytes
+  - Sirenix.Serialization.dll.bytes
+  - UniTask.dll.bytes

+ 1 - 3
Unity/Assets/Scripts/Codes/Hotfix/Unity.Hotfix.Codes.asmdef

@@ -8,9 +8,7 @@
         "Unity.Mathematics",
         "Unity.Loader"
     ],
-    "includePlatforms": [
-        "Editor"
-    ],
+    "includePlatforms": [],
     "excludePlatforms": [],
     "allowUnsafeCode": true,
     "overrideReferences": false,

+ 1 - 3
Unity/Assets/Scripts/Codes/HotfixView/Unity.HotfixView.Codes.asmdef

@@ -10,9 +10,7 @@
         "Unity.Mathematics",
         "Unity.Loader"
     ],
-    "includePlatforms": [
-        "Editor"
-    ],
+    "includePlatforms": [],
     "excludePlatforms": [],
     "allowUnsafeCode": true,
     "overrideReferences": false,

+ 1 - 3
Unity/Assets/Scripts/Codes/Model/Unity.Model.Codes.asmdef

@@ -6,9 +6,7 @@
         "Unity.Core",
         "Unity.Mathematics"
     ],
-    "includePlatforms": [
-        "Editor"
-    ],
+    "includePlatforms": [],
     "excludePlatforms": [],
     "allowUnsafeCode": true,
     "overrideReferences": false,

+ 1 - 3
Unity/Assets/Scripts/Codes/ModelView/Unity.ModelView.Codes.asmdef

@@ -8,9 +8,7 @@
         "Unity.Mathematics",
         "Unity.Loader"
     ],
-    "includePlatforms": [
-        "Editor"
-    ],
+    "includePlatforms": [],
     "excludePlatforms": [],
     "allowUnsafeCode": true,
     "overrideReferences": false,

+ 38 - 11
Unity/Assets/Scripts/Editor/BuildEditor/BuildAssembliesHelper.cs

@@ -11,10 +11,19 @@ namespace ET
 {
     public static class BuildAssembliesHelper
     {
-        public const string CodeDir = "Assets/Bundles/Code/";
+        public const string CodeDir = "Assets/Res/CodeDll/";
 
         public static void BuildModel(CodeOptimization codeOptimization, GlobalConfig globalConfig)
         {
+            string[] logicFiles = Directory.GetFiles(Define.BuildOutputDir, "Model_*");
+            foreach (string file in logicFiles)
+            {
+                File.Delete(file);
+            }
+
+            int random = RandomGenerator.RandomNumber(100000000, 999999999);
+            string logicFile = $"Model_{random}";
+
             List<string> codes;
 
             switch (globalConfig.CodeMode)
@@ -48,14 +57,14 @@ namespace ET
                     };
                     break;
                 default:
-                    throw new Exception("not found enum");
+                    throw new Exception("unknow 'CodeMode'");
             }
 
-            BuildAssembliesHelper.BuildMuteAssembly("Model", codes, Array.Empty<string>(), codeOptimization, globalConfig.CodeMode);
+            BuildMuteAssembly(logicFile, codes, Array.Empty<string>(), codeOptimization, globalConfig.CodeMode);
 
-            File.Copy(Path.Combine(Define.BuildOutputDir, $"Model.dll"), Path.Combine(CodeDir, $"Model.dll.bytes"), true);
-            File.Copy(Path.Combine(Define.BuildOutputDir, $"Model.pdb"), Path.Combine(CodeDir, $"Model.pdb.bytes"), true);
-            Debug.Log("copy Model.dll to Bundles/Code success!");
+            File.Copy(Path.Combine(Define.BuildOutputDir, $"{logicFile}.dll"), Path.Combine(CodeDir, $"Model.dll.bytes"), true);
+            File.Copy(Path.Combine(Define.BuildOutputDir, $"{logicFile}.pdb"), Path.Combine(CodeDir, $"Model.pdb.bytes"), true);
+            Debug.Log("copy Model.dll to Assets/Res/CodeDll success!");
         }
 
         public static void BuildHotfix(CodeOptimization codeOptimization, GlobalConfig globalConfig)
@@ -65,6 +74,16 @@ namespace ET
             {
                 File.Delete(file);
             }
+            string modelfile;
+            string[] modelFiles = Directory.GetFiles(Define.BuildOutputDir, "Model_*.dll");
+            if (modelFiles.Length > 0)
+            {
+                modelfile = modelFiles[0];
+            }
+            else
+            {
+                throw new Exception($"Not Found model_xx.dll @{Define.BuildOutputDir}");
+            }
 
             int random = RandomGenerator.RandomNumber(100000000, 999999999);
             string logicFile = $"Hotfix_{random}";
@@ -83,7 +102,9 @@ namespace ET
                 case CodeMode.Server:
                     codes = new List<string>()
                     {
-                        "Assets/Scripts/Codes/Hotfix/Share/", "Assets/Scripts/Codes/Hotfix/Server/", "Assets/Scripts/Codes/Hotfix/Client/",
+                        "Assets/Scripts/Codes/Hotfix/Share/", 
+                        "Assets/Scripts/Codes/Hotfix/Server/", 
+                        "Assets/Scripts/Codes/Hotfix/Client/",
                     };
                     break;
                 case CodeMode.ClientServer:
@@ -96,15 +117,14 @@ namespace ET
                     };
                     break;
                 default:
-                    throw new Exception("not found enum");
+                    throw new Exception("unknow 'CodeMode'");
             }
 
-            BuildAssembliesHelper.BuildMuteAssembly(logicFile, codes, new[] { Path.Combine(Define.BuildOutputDir, "Model.dll") }, codeOptimization,
-                globalConfig.CodeMode);
+            BuildMuteAssembly(logicFile, codes, new[] { modelfile }, codeOptimization, globalConfig.CodeMode);
 
             File.Copy(Path.Combine(Define.BuildOutputDir, $"{logicFile}.dll"), Path.Combine(CodeDir, $"Hotfix.dll.bytes"), true);
             File.Copy(Path.Combine(Define.BuildOutputDir, $"{logicFile}.pdb"), Path.Combine(CodeDir, $"Hotfix.pdb.bytes"), true);
-            Debug.Log("copy Hotfix.dll to Bundles/Code success!");
+            Debug.Log("copy Hotfix.dll to Assets/Res/CodeDll success!");
         }
 
         private static void BuildMuteAssembly(
@@ -185,6 +205,13 @@ namespace ET
                 if (warningCount > 0)
                 {
                     Debug.LogFormat("有{0}个Warning!!!", warningCount);
+                    for (int i = 0; i < compilerMessages.Length; i++)
+                    {
+                        if (compilerMessages[i].type == CompilerMessageType.Warning)
+                        {
+                            Debug.LogWarning(compilerMessages[i].message);
+                        }
+                    }
                 }
 
                 if (errorCount > 0)

+ 29 - 18
Unity/Assets/Scripts/Editor/BuildEditor/BuildEditor.cs

@@ -113,25 +113,20 @@ namespace ET
 			}
 			
 			GUILayout.Label("");
-			GUILayout.Label("Code Compile:");
-			
 			this.globalConfig.CodeMode = (CodeMode)EditorGUILayout.EnumPopup("CodeMode: ", this.globalConfig.CodeMode);
 			
 			if (GUILayout.Button("BuildModelAndHotfix"))
 			{
-				if (Define.EnableCodes)
-				{
-					throw new Exception("now in ENABLE_CODES mode, do not need Build!");
-				}
-				BuildAssembliesHelper.BuildModel(this.codeOptimization, globalConfig);
-				BuildAssembliesHelper.BuildHotfix(this.codeOptimization, globalConfig);
 
-				AfterCompiling();
-				
-				ShowNotification("Build Model And Hotfix Success!");
+				BuildModelAndHotfix(this.codeOptimization);
+                //用yooAsset打ab, 不用你了
+                //AfterCompiling();
+                ShowNotification("Build Model And Hotfix Success!");
 			}
-			
-			if (GUILayout.Button("BuildModel"))
+
+            GUILayout.Label("");
+            GUILayout.Label("Config Tools: =======================");
+            /*if (GUILayout.Button("BuildModel"))
 			{
 				if (Define.EnableCodes)
 				{
@@ -155,9 +150,9 @@ namespace ET
 				AfterCompiling();
 				
 				ShowNotification("Build Hotfix Success!");
-			}
-			
-			if (GUILayout.Button("ExcelExporter"))
+			}*/
+
+            if (GUILayout.Button("ExcelExporter"))
 			{
 				//Directory.Delete("Assets/Bundles/Config", true);
 				ToolsEditor.ExcelExporter();
@@ -176,8 +171,24 @@ namespace ET
 
 			GUILayout.Space(5);
 		}
+
+		public static void BuildModelAndHotfix(CodeOptimization codeOptimization = CodeOptimization.Release)
+		{
+            if (Define.EnableCodes)
+            {
+                throw new Exception("Remove macro 'ENABLE_CODES' first!");
+            }
+			var globalConfig = Resources.Load<GlobalConfig>("GlobalConfig");
+            if (globalConfig.CodeMode == CodeMode.Server)
+            {
+                throw new Exception("Don't compile server here, open 'ET.sln' to compile!");
+            }
+            BuildAssembliesHelper.BuildModel(codeOptimization, globalConfig);
+            BuildAssembliesHelper.BuildHotfix(codeOptimization, globalConfig);
+        }
 		
-		private static void AfterCompiling()
+		//将model.dll打包成ab
+		/*private static void AfterCompiling()
 		{
 			Directory.CreateDirectory(BuildAssembliesHelper.CodeDir);
 
@@ -188,7 +199,7 @@ namespace ET
 			AssetDatabase.Refresh();
             
 			Debug.Log("build success!");
-		}
+		}*/
 		
 		public static void ShowNotification(string tips)
 		{

+ 5 - 3
Unity/Assets/Scripts/Editor/HybridCLR/AssetBundleBuildCommand.cs

@@ -62,10 +62,12 @@ namespace HybridCLR.Editor
             
             //step 2
             PrebuildCommand.GenerateAll();
-            
+
             //step 3 copy
+            ET.BuildEditor.BuildModelAndHotfix();
+            //hotfix.dll不使用默认的打包,ET里面加了些骚操作
             // List<string> notSceneAssets = new List<string>();
-            string hotfixDllSrcDir = SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target);
+            /*string hotfixDllSrcDir = SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target);
             foreach (var dll in SettingsUtil.HotUpdateAssemblyFiles)
             {
                 string dllPath = $"{hotfixDllSrcDir}/{dll}";
@@ -73,7 +75,7 @@ namespace HybridCLR.Editor
                 File.Copy(dllPath, dllBytesPath, true);
                 // notSceneAssets.Add(dllBytesPath);
                 Debug.Log($"[BuildAssetBundles] copy hotfix dll {dllPath} -> {dllBytesPath}");
-            }
+            }*/
 
             //step 4
             string aotDllDir = SettingsUtil.GetAssembliesPostIl2CppStripDir(target);

+ 0 - 6
Unity/ProjectSettings/EditorBuildSettings.asset

@@ -8,10 +8,4 @@ EditorBuildSettings:
   - enabled: 1
     path: Assets/Scenes/Init.unity
     guid: e0d691ac8c1d0454ba07089ea820e18a
-  - enabled: 1
-    path: Assets/Scenes/Map1.unity
-    guid: a5294483f20f40d449699101bb428cda
-  - enabled: 1
-    path: Assets/Scenes/Map2.unity
-    guid: 064123f1e5067b249a9fd8967ddbde09
   m_configObjects: {}

+ 3 - 1
Unity/ProjectSettings/QualitySettings.asset

@@ -223,4 +223,6 @@ QualitySettings:
     resolutionScalingFixedDPIFactor: 1
     customRenderPipeline: {fileID: 0}
     excludedTargetPlatforms: []
-  m_PerPlatformDefaultQuality: {}
+  m_PerPlatformDefaultQuality:
+    Server: 0
+    Standalone: 0