BuildDllHelper.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // using System.IO;
  2. // using HybridCLR.Editor;
  3. // using UnityEditor;
  4. // using UnityEngine;
  5. // using GFGGame;
  6. // using System.Collections.Generic;
  7. //
  8. // namespace GFGEditor
  9. // {
  10. // public class BuildDllHelper
  11. // {
  12. // [InitializeOnLoadMethod]
  13. // public static void Init()
  14. // {
  15. // AssetBundleHelper.BuildHotUpdateDll = BuildHotUpdateDll;
  16. // }
  17. //
  18. // public static void BuildHotUpdateDll()
  19. // {
  20. // CompileDllCommand.CompileDllActiveBuildTarget();
  21. // CopyHotUpdateAssembliesToStreamingAssets();
  22. // }
  23. //
  24. // public static void CopyHotUpdateAssembliesToStreamingAssets()
  25. // {
  26. // var target = EditorUserBuildSettings.activeBuildTarget;
  27. //
  28. // string hotfixDllSrcDir = SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target);
  29. // string hotfixAssembliesDstDir = LauncherConfig.DllDirHotfix;
  30. // if (!Directory.Exists(LauncherConfig.DllDirHotfix))
  31. // {
  32. // Directory.CreateDirectory(LauncherConfig.DllDirHotfix);
  33. // }
  34. // List<string> HotUpdateAssemblyFiles = new List<string>() { "Game.HotUpdate.dll" };
  35. // foreach (var dll in HotUpdateAssemblyFiles)
  36. // {
  37. // string dllPath = $"{hotfixDllSrcDir}/{dll}";
  38. // string dllBytesPath = $"{hotfixAssembliesDstDir}{dll}.bytes";
  39. // File.Copy(dllPath, dllBytesPath, true);
  40. // Debug.Log($"[CopyHotUpdateAssembliesToStreamingAssets] copy hotfix dll {dllPath} -> {dllBytesPath}");
  41. // }
  42. // }
  43. //
  44. //
  45. // public static void CopyAOTAssembliesToStreamingAssets()
  46. // {
  47. // var target = EditorUserBuildSettings.activeBuildTarget;
  48. // string aotAssembliesSrcDir = SettingsUtil.GetAssembliesPostIl2CppStripDir(target);
  49. // string aotAssembliesDstDir = LauncherConfig.DllDirAOT;
  50. // if(!Directory.Exists(LauncherConfig.DllDirAOT))
  51. // {
  52. // Directory.CreateDirectory(LauncherConfig.DllDirAOT);
  53. // }
  54. //
  55. // foreach (var dll in HotUpdateCodeLoader.AOTMetaAssemblyNames)
  56. // {
  57. // string srcDllPath = $"{aotAssembliesSrcDir}/{dll}";
  58. // if (!File.Exists(srcDllPath))
  59. // {
  60. // Debug.LogError($"ab中添加AOT补充元数据dll:{srcDllPath} 时发生错误,文件不存在。裁剪后的AOT dll在BuildPlayer时才能生成,因此需要你先构建一次游戏App后再打包。");
  61. // continue;
  62. // }
  63. // string dllBytesPath = $"{aotAssembliesDstDir}{dll}.bytes";
  64. // File.Copy(srcDllPath, dllBytesPath, true);
  65. // Debug.Log($"[CopyAOTAssembliesToStreamingAssets] copy AOT dll {srcDllPath} -> {dllBytesPath}");
  66. // }
  67. // }
  68. //
  69. // }
  70. // }