using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
public class CheckAssetsUpdate : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
// Addressables.LoadAssetAsync<GameObject>("Capsule").Completed += CheckAssetsUpdate_Completed;
Addressables.LoadAssetAsync<TextAsset>("HotUpdate.dll").Completed += CheckAssetsUpdate_Completed;
}
private void CheckAssetsUpdate_Completed(AsyncOperationHandle<TextAsset> obj)
{
Assembly hotUpdateAss = Assembly.Load(obj.Result.bytes);
Type type = hotUpdateAss.GetType("Hello");
type.GetMethod("Run").Invoke(null,null);
}
// Update is called once per frame
void Update()
{
}
}
CheckAssetsUpdate 挂载之后 将原来Hello脚本的语句修改

脚本变动重新编译一下 动过的代码重新生成DLL

找到工程目录里的Dll,将其更改名称为HotUpdate.dll.bytes 复制替换热更文件夹下的DLL


出新的代码资源包

需要Load的资源上传服务器

程序输出Hello, Word!33333333333 证明脚本资源热更实现了!
