DllHelper.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System.IO;
  2. using UnityEditor;
  3. using UnityEngine;
  4. using HybridCLR;
  5. namespace GFGEditor
  6. {
  7. public static class DllHelper
  8. {
  9. public static void BuildDll(string codeDir, BuildTarget target)
  10. {
  11. Directory.CreateDirectory(codeDir);
  12. CompileDllHelper.CompileDll(target);
  13. string hotfixDllSrcDir = BuildConfig.GetHotFixDllsOutputDirByTarget(target);
  14. foreach (var dll in BuildConfig.AllHotUpdateDllNames)
  15. {
  16. string dllPath = $"{hotfixDllSrcDir}/{dll}";
  17. string dllBytesPath = $"{codeDir}/{dll}.bytes";
  18. File.Copy(dllPath, dllBytesPath, true);
  19. }
  20. AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
  21. }
  22. public static void CopyAOTDll(string codeDir, BuildTarget target)
  23. {
  24. Directory.CreateDirectory(codeDir);
  25. string aotDllDir = BuildConfig.GetAssembliesPostIl2CppStripDir(target);
  26. foreach (var dll in BuildConfig.AOTMetaDlls)
  27. {
  28. string dllPath = $"{aotDllDir}/{dll}";
  29. if (!File.Exists(dllPath))
  30. {
  31. Debug.LogError($"ab中添加AOT补充元数据dll:{dllPath} 时发生错误,文件不存在。裁剪后的AOT dll在BuildPlayer时才能生成,因此需要你先构建一次游戏App后再打包。");
  32. continue;
  33. }
  34. string dllBytesPath = $"{codeDir}/{dll}.bytes";
  35. File.Copy(dllPath, dllBytesPath, true);
  36. }
  37. AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
  38. }
  39. }
  40. }