浏览代码

添加热更条件判断

taochangchun 1 周之前
父节点
当前提交
ec2f856c58
共有 3 个文件被更改,包括 23 次插入16 次删除
  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
 using HybridCLR.Editor.Commands;
2
 using HybridCLR.Editor.Commands;
3
+using HybridCLR.Editor;
4
+#endif
3
 using Newtonsoft.Json;
5
 using Newtonsoft.Json;
4
 using System;
6
 using System;
5
 using System.Collections;
7
 using System.Collections;
@@ -16,17 +18,17 @@ namespace TModule.Editor
16
 {
18
 {
17
     public class AssetBudleTool : EditorWindow
19
     public class AssetBudleTool : EditorWindow
18
     {
20
     {
19
-        private string AssetBudleConfigName= "AssetBundleConfig.asset";
21
+        private string AssetBudleConfigName = "AssetBundleConfig.asset";
20
         private string AssetBudleConfigPath;
22
         private string AssetBudleConfigPath;
21
         private string AssetbudleToolConfigName = "BudleToolConfig.asset";
23
         private string AssetbudleToolConfigName = "BudleToolConfig.asset";
22
-        private  string AssetbudleToolConfigPath;
24
+        private string AssetbudleToolConfigPath;
23
         private AssetBudleConfig _list;
25
         private AssetBudleConfig _list;
24
         private AssetBudleConfig BudleConfig
26
         private AssetBudleConfig BudleConfig
25
         {
27
         {
26
             get
28
             get
27
             {
29
             {
28
                 _list = _list ?? AssetDatabase.LoadAssetAtPath<AssetBudleConfig>(AssetBudleConfigPath);
30
                 _list = _list ?? AssetDatabase.LoadAssetAtPath<AssetBudleConfig>(AssetBudleConfigPath);
29
-                if(_list==null)
31
+                if (_list == null)
30
                 {
32
                 {
31
                     _list = CreateInstance<AssetBudleConfig>();
33
                     _list = CreateInstance<AssetBudleConfig>();
32
                     AssetDatabase.CreateAsset(_list, AssetBudleConfigPath);
34
                     AssetDatabase.CreateAsset(_list, AssetBudleConfigPath);
@@ -43,7 +45,7 @@ namespace TModule.Editor
43
             get
45
             get
44
             {
46
             {
45
                 _toolConfig = _toolConfig ?? AssetDatabase.LoadAssetAtPath<AssetBudleToolConfig>(AssetbudleToolConfigPath);
47
                 _toolConfig = _toolConfig ?? AssetDatabase.LoadAssetAtPath<AssetBudleToolConfig>(AssetbudleToolConfigPath);
46
-                if(_toolConfig==null)
48
+                if (_toolConfig == null)
47
                 {
49
                 {
48
                     _toolConfig = CreateInstance<AssetBudleToolConfig>();
50
                     _toolConfig = CreateInstance<AssetBudleToolConfig>();
49
                     AssetDatabase.CreateAsset(_toolConfig, AssetbudleToolConfigPath);
51
                     AssetDatabase.CreateAsset(_toolConfig, AssetbudleToolConfigPath);
@@ -172,9 +174,12 @@ namespace TModule.Editor
172
             SetABName();
174
             SetABName();
173
             BuildPipeline.BuildAssetBundles(tartgetPath, BuildAssetBundleOptions.None, _buildTarget);
175
             BuildPipeline.BuildAssetBundles(tartgetPath, BuildAssetBundleOptions.None, _buildTarget);
174
 
176
 
177
+#if HybridCLR
175
             CompileDllCommand.CompileDll(_buildTarget);
178
             CompileDllCommand.CompileDll(_buildTarget);
179
+
176
             CopyAOTAssembliesToPath(tartgetPath);
180
             CopyAOTAssembliesToPath(tartgetPath);
177
             CopyHotUpdateAssembliesToPath(tartgetPath);
181
             CopyHotUpdateAssembliesToPath(tartgetPath);
182
+#endif
178
             if (BudleToolConfig.m_copyToStreamingAssets)
183
             if (BudleToolConfig.m_copyToStreamingAssets)
179
                 CopyToStreamingAssets();
184
                 CopyToStreamingAssets();
180
 
185
 
@@ -189,7 +194,7 @@ namespace TModule.Editor
189
                 AssetBundleEntity assetBudle = BudleConfig.m_AB[i];
194
                 AssetBundleEntity assetBudle = BudleConfig.m_AB[i];
190
                 if (assetBudle.m_isFolder)
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
                     SaveFolderSettings(floderArr);
198
                     SaveFolderSettings(floderArr);
194
                 }
199
                 }
195
                 else
200
                 else
@@ -230,7 +235,7 @@ namespace TModule.Editor
230
                 string variant = file.Extension.Equals(".unity", StringComparison.CurrentCultureIgnoreCase) ? "unity3d" : "assetbundle";
235
                 string variant = file.Extension.Equals(".unity", StringComparison.CurrentCultureIgnoreCase) ? "unity3d" : "assetbundle";
231
 
236
 
232
                 AssetImporter importer = AssetImporter.GetAtPath(newPath);
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
                     importer.SetAssetBundleNameAndVariant(fileName, variant);
240
                     importer.SetAssetBundleNameAndVariant(fileName, variant);
236
                     importer.SaveAndReimport();
241
                     importer.SaveAndReimport();
@@ -242,7 +247,7 @@ namespace TModule.Editor
242
         {
247
         {
243
             string toPath = Application.streamingAssetsPath;
248
             string toPath = Application.streamingAssetsPath;
244
             string tartgetPath = BudleToolConfig.m_savePath + "/" + _buildTarget.ToString();
249
             string tartgetPath = BudleToolConfig.m_savePath + "/" + _buildTarget.ToString();
245
-            CopyDirectory(tartgetPath, toPath,true);
250
+            CopyDirectory(tartgetPath, toPath, true);
246
             AssetDatabase.Refresh();
251
             AssetDatabase.Refresh();
247
         }
252
         }
248
 
253
 
@@ -380,11 +385,12 @@ namespace TModule.Editor
380
             }
385
             }
381
         }
386
         }
382
 
387
 
388
+#if HybridCLR
383
         public void CopyAOTAssembliesToPath(string path)
389
         public void CopyAOTAssembliesToPath(string path)
384
         {
390
         {
385
             string aotAssembliesSrcDir = SettingsUtil.GetAssembliesPostIl2CppStripDir(_buildTarget);
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
                 string srcDllPath = $"{aotAssembliesSrcDir}/{dll}";
395
                 string srcDllPath = $"{aotAssembliesSrcDir}/{dll}";
390
                 if (!File.Exists(srcDllPath))
396
                 if (!File.Exists(srcDllPath))
@@ -414,5 +420,6 @@ namespace TModule.Editor
414
             }
420
             }
415
             AssetDatabase.Refresh();
421
             AssetDatabase.Refresh();
416
         }
422
         }
423
+#endif
417
     }
424
     }
418
 }
425
 }

+ 4 - 4
Editor/AssetBundleConfig.asset

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

+ 2 - 2
Runtime/HotfixManager.cs

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