| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 | using System.IO;using HybridCLR.Editor;using UnityEditor;using UnityEngine;using GFGGame;using HybridCLR.Editor.Commands;using System.Collections.Generic;namespace GFGEditor{    public class BuildDllHelper    {        [InitializeOnLoadMethod]        public static void Init()        {            AssetBundleHelper.BuildHotUpdateDll = BuildHotUpdateDll;        }        public static void BuildHotUpdateDll()        {            CompileDllCommand.CompileDllActiveBuildTarget();            CopyHotUpdateAssembliesToStreamingAssets();        }        public static void CopyHotUpdateAssembliesToStreamingAssets()        {            var target = EditorUserBuildSettings.activeBuildTarget;            string hotfixDllSrcDir = SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target);            string hotfixAssembliesDstDir = LauncherConfig.DllDirHotfix;            if (!Directory.Exists(LauncherConfig.DllDirHotfix))            {                Directory.CreateDirectory(LauncherConfig.DllDirHotfix);            }            List<string> HotUpdateAssemblyFiles = new List<string>() { "Game.HotUpdate.dll" };            foreach (var dll in 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;            if(!Directory.Exists(LauncherConfig.DllDirAOT))            {                Directory.CreateDirectory(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}");            }        }    }}
 |