35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
|
|
using HybridCLR;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Reflection;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using YooAsset;
|
|||
|
|
|
|||
|
|
public class HotDllLoader : Singleton<HotDllLoader>
|
|||
|
|
{
|
|||
|
|
public void LoadDll(ResourcePackage package, string dll)
|
|||
|
|
{
|
|||
|
|
if (package.GetAssetInfo(dll).Error == string.Empty)
|
|||
|
|
{
|
|||
|
|
AssetHandle handle = package.LoadAssetSync<TextAsset>(dll);
|
|||
|
|
#if UNITY_EDITOR
|
|||
|
|
Assembly hotUpdateAss = System.AppDomain.CurrentDomain.GetAssemblies().First(a => a.GetName().Name == dll.Replace(".dll", ""));
|
|||
|
|
#else
|
|||
|
|
Assembly hotUpdateAss = Assembly.Load((handle.AssetObject as TextAsset).bytes);
|
|||
|
|
#endif
|
|||
|
|
Debug.Log($"<22><><EFBFBD><EFBFBD>{dll}");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
public void LoadDepDll(ResourcePackage package, List<string> dlls)
|
|||
|
|
{
|
|||
|
|
foreach (string dll in dlls)
|
|||
|
|
{
|
|||
|
|
if (package.GetAssetInfo(dll).Error == string.Empty)
|
|||
|
|
{
|
|||
|
|
AssetHandle handle = package.LoadAssetSync<TextAsset>(dll);
|
|||
|
|
RuntimeApi.LoadMetadataForAOTAssembly((handle.AssetObject as TextAsset).bytes, HomologousImageMode.SuperSet);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|