44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
using UnityEngine;
|
|
|
|
namespace ShrinkModFramework
|
|
{
|
|
public static class ShrinkModRuntimeBootstrap
|
|
{
|
|
/// <summary>
|
|
/// 显式创建或更新模组运行时驱动。安全启动链可先调用此入口,再调用
|
|
/// ShrinkModLoader.LoadAuthorized 提交已校验的 DLL 白名单。
|
|
/// </summary>
|
|
public static void InitializeDriver(ShrinkModFrameworkSettings settings = null)
|
|
{
|
|
ShrinkModRuntimeDriver.EnsureCreated(settings ?? ShrinkModFrameworkSettings.Instance);
|
|
}
|
|
|
|
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
|
|
private static void ResetStaticStateForPlayMode()
|
|
{
|
|
ShrinkModLoader.ResetForDomainReload();
|
|
ShrinkModNetworkManager.ResetForDomainReload();
|
|
}
|
|
|
|
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
|
|
private static void AutoLoad()
|
|
{
|
|
var settings = ShrinkModFrameworkSettings.Instance;
|
|
if (settings && !settings.autoLoadOnStartup)
|
|
return;
|
|
|
|
InitializeDriver(settings);
|
|
|
|
try
|
|
{
|
|
ShrinkModLoader.LoadAll(settings);
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
Debug.LogException(ex);
|
|
Debug.LogError($"[ShrinkModFramework] 自动启动失败:{ex.Message}");
|
|
}
|
|
}
|
|
}
|
|
}
|