using System.IO; using HybridCLR.Editor; using UnityEditor; using UnityEngine; using GFGGame; using HybridCLR.Editor.Commands; namespace GFGEditor { public class BuildDllHelper { public static void BuildHotUpdateDll() { CompileDllCommand.CompileDllActiveBuildTarget(); CopyHotUpdateAssembliesToStreamingAssets(); } public static void CopyHotUpdateAssembliesToStreamingAssets() { var target = EditorUserBuildSettings.activeBuildTarget; string hotfixDllSrcDir = SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target); string hotfixAssembliesDstDir = LauncherConfig.DllDirHotfix; foreach (var dll in SettingsUtil.HotUpdateAssemblyFiles) { string dllPath = $"{hotfixDllSrcDir}/{dll}"; string dllBytesPath = $"{hotfixAssembliesDstDir}{dll}.bytes"; File.Copy(dllPath, dllBytesPath, true); Debug.Log($"[CopyHotUpdateAssembliesToStreamingAssets] copy hotfix dll {dllPath} -> {dllBytesPath}"); } } public static void CopyAOTAssembliesToStreamingAssets() { var target = EditorUserBuildSettings.activeBuildTarget; string aotAssembliesSrcDir = SettingsUtil.GetAssembliesPostIl2CppStripDir(target); string aotAssembliesDstDir = LauncherConfig.DllDirAOT; foreach (var dll in HotUpdateCodeLoader.AOTMetaAssemblyNames) { string srcDllPath = $"{aotAssembliesSrcDir}/{dll}"; if (!File.Exists(srcDllPath)) { Debug.LogError($"ab中添加AOT补充元数据dll:{srcDllPath} 时发生错误,文件不存在。裁剪后的AOT dll在BuildPlayer时才能生成,因此需要你先构建一次游戏App后再打包。"); continue; } string dllBytesPath = $"{aotAssembliesDstDir}{dll}.bytes"; File.Copy(srcDllPath, dllBytesPath, true); Debug.Log($"[CopyAOTAssembliesToStreamingAssets] copy AOT dll {srcDllPath} -> {dllBytesPath}"); } } } }