編輯器打包到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補(bǔ)充元數(shù)據(jù)dll:{
srcDllPath} 時(shí)發(fā)生錯(cuò)誤,文件不存在。裁剪后的AOT dll在BuildPlayer時(shí)才能生成,因此需要你先構(gòu)建一次游戲App后再打包。");
continue;
}
string dllBytesPath = $"{
aotAssembliesDstDir}/{
dll}.dll.bytes";
File.Copy(srcDllPath, dllBytesPath, true);
Debug.Log($"[CopyAOTAssembliesToStreamingAssets] copy AOT dll {
srcDllPath} -> {
dllBytesPath}");
AddAssetToGroup(
文章來源地址http://www.zghlxwxcb.cn/news/detail-535340.html
文章來源:http://www.zghlxwxcb.cn/news/detail-535340.html
到了這里,關(guān)于Unity熱更新HybridCLR+Addressables的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!