This commit is contained in:
@@ -9,7 +9,7 @@ namespace ShrinkModFramework
|
||||
[SerializeField] private ShrinkModFrameworkSettings settingsOverride;
|
||||
|
||||
[Header("Bootstrap")]
|
||||
[SerializeField] private bool autoLoadOnAwake = true;
|
||||
[SerializeField] private bool autoLoadOnAwake;
|
||||
|
||||
private static bool _bootstrapped;
|
||||
|
||||
|
||||
@@ -5,6 +5,10 @@ namespace ShrinkModFramework
|
||||
[CreateAssetMenu(fileName = "ShrinkModFrameworkSettings", menuName = "ShrinkSDK/模组/模组设置")]
|
||||
public class ShrinkModFrameworkSettings : ScriptableObject
|
||||
{
|
||||
public const string PreferredResourcesPath =
|
||||
"GameAssets/Runtime/Data/ShrinkSDK/ShrinkModFrameworkSettings";
|
||||
public const string LegacyResourcesPath = "ShrinkModFrameworkSettings";
|
||||
|
||||
private static ShrinkModFrameworkSettings _instance;
|
||||
|
||||
public static ShrinkModFrameworkSettings Instance
|
||||
@@ -13,7 +17,9 @@ namespace ShrinkModFramework
|
||||
{
|
||||
if (_instance) return _instance;
|
||||
|
||||
_instance = Resources.Load<ShrinkModFrameworkSettings>("ShrinkModFrameworkSettings");
|
||||
_instance = Resources.Load<ShrinkModFrameworkSettings>(PreferredResourcesPath);
|
||||
if (!_instance)
|
||||
_instance = Resources.Load<ShrinkModFrameworkSettings>(LegacyResourcesPath);
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (!_instance)
|
||||
@@ -39,8 +45,13 @@ namespace ShrinkModFramework
|
||||
internal set => _instance = value;
|
||||
}
|
||||
|
||||
internal static void ResetCachedInstance()
|
||||
{
|
||||
_instance = null;
|
||||
}
|
||||
|
||||
[Header("Bootstrap")]
|
||||
public bool autoLoadOnStartup = true;
|
||||
public bool autoLoadOnStartup;
|
||||
[Tooltip("使用 ShrinkContextHost 协调模组组件;关闭时回退到旧的只增不减 ShrinkModLoader。")]
|
||||
public bool useContextHost = true;
|
||||
|
||||
@@ -51,10 +62,10 @@ namespace ShrinkModFramework
|
||||
public string[] assemblyNamePrefixes = new string[0];
|
||||
|
||||
[Header("External Mods")]
|
||||
public bool enableExternalDllMods = true;
|
||||
public bool enableExternalDllMods;
|
||||
public bool autoCreateExternalModsDirectory = true;
|
||||
public string externalModsFolderName = "Mods";
|
||||
public bool watchExternalModsDirectory = true;
|
||||
public bool watchExternalModsDirectory;
|
||||
public float externalModsReloadDelaySeconds = 0.5f;
|
||||
[Min(1)]
|
||||
[Tooltip("Mono 下外部程序集 revision 会常驻;历史数量达到该软阈值后提示 Domain Reload/重启。")]
|
||||
|
||||
@@ -4,6 +4,15 @@ 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()
|
||||
{
|
||||
@@ -15,11 +24,11 @@ namespace ShrinkModFramework
|
||||
private static void AutoLoad()
|
||||
{
|
||||
var settings = ShrinkModFrameworkSettings.Instance;
|
||||
ShrinkModRuntimeDriver.EnsureCreated(settings);
|
||||
|
||||
if (settings && !settings.autoLoadOnStartup)
|
||||
return;
|
||||
|
||||
InitializeDriver(settings);
|
||||
|
||||
try
|
||||
{
|
||||
ShrinkModLoader.LoadAll(settings);
|
||||
|
||||
Reference in New Issue
Block a user