feat(cordis): 接入上下文组合与模组事务热替换
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ShrinkModFramework
|
||||
{
|
||||
[DefaultExecutionOrder(-2100)]
|
||||
public sealed class ShrinkModBootstrap : MonoBehaviour
|
||||
{
|
||||
[Header("Override (留空则只使用组件上的选项)")]
|
||||
[SerializeField] private ShrinkModFrameworkSettings settingsOverride;
|
||||
|
||||
[Header("Bootstrap")]
|
||||
[SerializeField] private bool autoLoadOnAwake = true;
|
||||
|
||||
private static bool _bootstrapped;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (_bootstrapped)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
_bootstrapped = true;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
|
||||
var shouldAutoLoad = settingsOverride ? settingsOverride.autoLoadOnStartup : autoLoadOnAwake;
|
||||
if (shouldAutoLoad)
|
||||
ShrinkModLoader.LoadAll(settingsOverride);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user