编辑器打包到Addressables
using HybridCLR.Editor;
using HybridCLR.Editor.Commands;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEditor.AddressableAssets.Settings.GroupSchemas;
using UnityEditor.AddressableAssets.Settings;
using UnityEditor.AddressableAssets;
using UnityEngine;
public static class HotUpdateHelper
{
[MenuItem("HybridCLR/编译热更DLL,并且拷贝到Addressable")]
public static void Copy2Addressable()
{
CompileDllCommand.CompileDllActiveBuildTarget();//官方提供脚本
CopyAOTAssembliesToCache();
CopyHotUpdateAssembliesToCache();
//刷新资源
AssetDatabase.Refresh();
}
public static void CopyAOTAssembliesToCache()
{
var target = EditorUserBuildSettings.activeBuildTarget;
string aotAssembliesSrcDir = SettingsUtil.GetAssembliesPostIl2CppStripDir(target);
string aotAssembliesDstDir = Application.dataPath + $"/HybridCLRBuildCache/AssetBundleOutput/StandaloneWindows64";
foreach (var dll in SettingsUtil.AOTAssemblyNames)
{
string srcDllPath = $"{
aotAssembliesSrcDir}/{
dll}.dll";
if (!File.Exists(srcDllPath))
{
Debug.LogError($"ab中添加AOT补充元数据dll:{
srcDllPath} 时发生错误,文件不存在。裁剪后的AOT dll在BuildPlayer时才能生成,因此需要你先构建一次游戏App后再打包。");
continue;
}
string dllBytesPath = $"{
aotAssembliesDstDir}/{
dll}.dll.bytes";
File.Copy(srcDllPath, dllBytesPath, true);
Debug.Log($"[CopyAOTAssembliesToStreamingAssets] copy AOT dll {
srcDllPath} -> {
dllBytesPath}");
AddAssetToGroup(
文章来源地址https://www.toymoban.com/news/detail-535340.html
文章来源:https://www.toymoban.com/news/detail-535340.html
到了这里,关于Unity热更新HybridCLR+Addressables的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!