Pārlūkot izejas kodu

添加热更条件判断

taochangchun 1 nedēļu atpakaļ
vecāks
revīzija
ec2f856c58
3 mainītis faili ar 23 papildinājumiem un 16 dzēšanām
  1. 17 10
      Editor/AssetBudleTool.cs
  2. 4 4
      Editor/AssetBundleConfig.asset
  3. 2 2
      Runtime/HotfixManager.cs

+ 17 - 10
Editor/AssetBudleTool.cs

@@ -1,5 +1,7 @@
1
-using HybridCLR.Editor;
1
+#if HybridCLR
2 2
 using HybridCLR.Editor.Commands;
3
+using HybridCLR.Editor;
4
+#endif
3 5
 using Newtonsoft.Json;
4 6
 using System;
5 7
 using System.Collections;
@@ -16,17 +18,17 @@ namespace TModule.Editor
16 18
 {
17 19
     public class AssetBudleTool : EditorWindow
18 20
     {
19
-        private string AssetBudleConfigName= "AssetBundleConfig.asset";
21
+        private string AssetBudleConfigName = "AssetBundleConfig.asset";
20 22
         private string AssetBudleConfigPath;
21 23
         private string AssetbudleToolConfigName = "BudleToolConfig.asset";
22
-        private  string AssetbudleToolConfigPath;
24
+        private string AssetbudleToolConfigPath;
23 25
         private AssetBudleConfig _list;
24 26
         private AssetBudleConfig BudleConfig
25 27
         {
26 28
             get
27 29
             {
28 30
                 _list = _list ?? AssetDatabase.LoadAssetAtPath<AssetBudleConfig>(AssetBudleConfigPath);
29
-                if(_list==null)
31
+                if (_list == null)
30 32
                 {
31 33
                     _list = CreateInstance<AssetBudleConfig>();
32 34
                     AssetDatabase.CreateAsset(_list, AssetBudleConfigPath);
@@ -43,7 +45,7 @@ namespace TModule.Editor
43 45
             get
44 46
             {
45 47
                 _toolConfig = _toolConfig ?? AssetDatabase.LoadAssetAtPath<AssetBudleToolConfig>(AssetbudleToolConfigPath);
46
-                if(_toolConfig==null)
48
+                if (_toolConfig == null)
47 49
                 {
48 50
                     _toolConfig = CreateInstance<AssetBudleToolConfig>();
49 51
                     AssetDatabase.CreateAsset(_toolConfig, AssetbudleToolConfigPath);
@@ -172,9 +174,12 @@ namespace TModule.Editor
172 174
             SetABName();
173 175
             BuildPipeline.BuildAssetBundles(tartgetPath, BuildAssetBundleOptions.None, _buildTarget);
174 176
 
177
+#if HybridCLR
175 178
             CompileDllCommand.CompileDll(_buildTarget);
179
+
176 180
             CopyAOTAssembliesToPath(tartgetPath);
177 181
             CopyHotUpdateAssembliesToPath(tartgetPath);
182
+#endif
178 183
             if (BudleToolConfig.m_copyToStreamingAssets)
179 184
                 CopyToStreamingAssets();
180 185
 
@@ -189,7 +194,7 @@ namespace TModule.Editor
189 194
                 AssetBundleEntity assetBudle = BudleConfig.m_AB[i];
190 195
                 if (assetBudle.m_isFolder)
191 196
                 {
192
-                    string[] floderArr = new string[] {GetAbsolutePath(assetBudle.m_name) };
197
+                    string[] floderArr = new string[] { GetAbsolutePath(assetBudle.m_name) };
193 198
                     SaveFolderSettings(floderArr);
194 199
                 }
195 200
                 else
@@ -230,7 +235,7 @@ namespace TModule.Editor
230 235
                 string variant = file.Extension.Equals(".unity", StringComparison.CurrentCultureIgnoreCase) ? "unity3d" : "assetbundle";
231 236
 
232 237
                 AssetImporter importer = AssetImporter.GetAtPath(newPath);
233
-                if(importer.assetBundleName=="None" || string.IsNullOrEmpty(importer.assetBundleName))
238
+                if (importer.assetBundleName == "None" || string.IsNullOrEmpty(importer.assetBundleName))
234 239
                 {
235 240
                     importer.SetAssetBundleNameAndVariant(fileName, variant);
236 241
                     importer.SaveAndReimport();
@@ -242,7 +247,7 @@ namespace TModule.Editor
242 247
         {
243 248
             string toPath = Application.streamingAssetsPath;
244 249
             string tartgetPath = BudleToolConfig.m_savePath + "/" + _buildTarget.ToString();
245
-            CopyDirectory(tartgetPath, toPath,true);
250
+            CopyDirectory(tartgetPath, toPath, true);
246 251
             AssetDatabase.Refresh();
247 252
         }
248 253
 
@@ -380,11 +385,12 @@ namespace TModule.Editor
380 385
             }
381 386
         }
382 387
 
388
+#if HybridCLR
383 389
         public void CopyAOTAssembliesToPath(string path)
384 390
         {
385 391
             string aotAssembliesSrcDir = SettingsUtil.GetAssembliesPostIl2CppStripDir(_buildTarget);
386
-            List<string> aotMetaAssemblyFiles = Resources.Load<HotfixConfig>("HotfixUpdate/ÈȸüÅäÖñí").m_hotfixUpdateAotDlls;
387
-            foreach (var dll in aotMetaAssemblyFiles)
392
+
393
+            foreach (var dll in Resources.Load<HotfixConfig>("HotfixUpdate/ÈȸüÅäÖñí").m_hotfixUpdateAotDlls)
388 394
             {
389 395
                 string srcDllPath = $"{aotAssembliesSrcDir}/{dll}";
390 396
                 if (!File.Exists(srcDllPath))
@@ -414,5 +420,6 @@ namespace TModule.Editor
414 420
             }
415 421
             AssetDatabase.Refresh();
416 422
         }
423
+#endif
417 424
     }
418 425
 }

+ 4 - 4
Editor/AssetBundleConfig.asset

@@ -30,7 +30,7 @@ MonoBehaviour:
30 30
     m_isFolder: 1
31 31
     m_isFirstData: 0
32 32
   - m_key: 
33
-    m_name: Assets/Code/Env1/HotUpdateResources/Resources
33
+    m_name: Assets/Code/Env1/HotUpdateResources/Sprites
34 34
     m_tag: 
35 35
     m_version: 0
36 36
     m_size: 0
@@ -38,7 +38,7 @@ MonoBehaviour:
38 38
     m_isFolder: 1
39 39
     m_isFirstData: 0
40 40
   - m_key: 
41
-    m_name: Assets/Code/Env1/HotUpdateResources/Sprites
41
+    m_name: Assets/Code/Env1/HotUpdateResources/Scenes
42 42
     m_tag: 
43 43
     m_version: 0
44 44
     m_size: 0
@@ -46,7 +46,7 @@ MonoBehaviour:
46 46
     m_isFolder: 1
47 47
     m_isFirstData: 0
48 48
   - m_key: 
49
-    m_name: Assets/Code/Env1/HotUpdateResources/Scenes
49
+    m_name: Assets/Code/Env1/HotUpdateResources/Fonts
50 50
     m_tag: 
51 51
     m_version: 0
52 52
     m_size: 0
@@ -54,7 +54,7 @@ MonoBehaviour:
54 54
     m_isFolder: 1
55 55
     m_isFirstData: 0
56 56
   - m_key: 
57
-    m_name: Assets/Code/Env1/HotUpdateResources/Fonts
57
+    m_name: Assets/Code/Env1/HotUpdateResources/TResources
58 58
     m_tag: 
59 59
     m_version: 0
60 60
     m_size: 0

+ 2 - 2
Runtime/HotfixManager.cs

@@ -63,7 +63,7 @@ namespace TModule.Runtime {
63 63
 #elif UNITY_STANDALONE_OSX
64 64
                 return "Mac";
65 65
 #elif UNITY_STANDALONE_WIN
66
-                return "Windows";
66
+                return "StandaloneWindows64";
67 67
 #elif UNITY_WEBGL
68 68
                 return "WebGL";
69 69
 #else
@@ -182,7 +182,7 @@ namespace TModule.Runtime {
182 182
 #endif
183 183
                 return;
184 184
             }
185
-            if(loadMode==UpdateMode.Editor||!isHotfix)
185
+            if(AssetConfig.RuntimeMode == UpdateMode.Editor||!isHotfix)
186 186
             {
187 187
                 Csharp = AppDomain.CurrentDomain.Load(hotfixDllName);
188 188
             }