public static void Start(UserCodeExceptionCatchMode exceptionMode, Func <IHostScreen, UniTask> func) { ProcessHelper.SingleLaunch(() => { _func = func; Launch(exceptionMode); }, () => throw new InvalidOperationException("Multiple engines cannot be started at the same time.")); }
private static void Launch(UserCodeExceptionCatchMode exceptionMode) { EngineSetting.UserCodeExceptionCatchMode = exceptionMode; try { Elffy.Diagnostics.DevEnv.Run(); Engine.Run(); var screen = CreateScreen(); screen.Initialized += OnScreenInitialized; CustomSynchronizationContext.Install(out var syncContextReciever); screen.Activate(); while (Engine.HandleOnce()) { syncContextReciever?.DoAll(); } } finally { CustomSynchronizationContext.Restore(); Engine.Stop(); Elffy.Diagnostics.DevEnv.Stop(); } }