using System.Collections;
using UnityEngine;
namespace ProjectM.Client
{
///
/// Persistent (DontDestroyOnLoad) MonoBehaviour that hosts the world-lifecycle coroutines for
/// . World create/dispose + scene loads must run at a FRAME BOUNDARY (never
/// inside an ECS system update — that crashes), and must survive the MainMenu<->Game scene swap, so a
/// single long-lived runner owns them. Created lazily on first use.
///
public class SessionRunner : MonoBehaviour
{
static SessionRunner _instance;
static SessionRunner Instance
{
get
{
if (_instance == null)
{
var go = new GameObject("~SessionRunner");
DontDestroyOnLoad(go);
_instance = go.AddComponent();
}
return _instance;
}
}
public static void Run(IEnumerator routine) => Instance.StartCoroutine(routine);
}
}