forked from sinai-dev/UnityExplorer
-
-
Notifications
You must be signed in to change notification settings - Fork 69
Open
Labels
questionFurther information is requestedFurther information is requested
Description
Hello,
For context, I am currently with a game built on Unity 6000, using a MelonLoader nightly build (IL2CPP), and the latest version of UnityExplorer.
My goal is to execute a command, wait for a few seconds (or wait for a scene to reload), and then execute another command. For example: calling a RestartGame() method, waiting for the new scene to load, and then modifying a newly spawned manager.
However, I've hit a wall trying to implement a delay inside the REPL / startup.cs evaluator:
System.Threading.Thread.Sleep(5000)freezes the Unity Main Thread entirely, so the game never actually loads the new scene during the wait.Task.Delay().ContinueWith(...)throws aSystem.InvalidOperationException: The current SynchronizationContext may not be used as a TaskSchedulererror in the REPL.- Trying to wrap the code inside a local function, a
class, or anIEnumerator(to useWaitForSecondsor MelonCoroutines) results in Mono Evaluator syntax errors likeerror CS1525: Unexpected symbolorerror CS0201. The evaluator seems to strictly process top-to-bottom flat statements.
My questions:
- Is there a built-in UnityExplorer method or a specific REPL syntax trick to achieve a non-blocking wait/yield inside
startup.cs? - If not, would it be possible to consider adding a built-in UE helper for this in the future? (e.g., something like
UnityExplorer.Wait(5f, () => { /* code */ });that handles the Coroutine safely behind the scenes).
Thank you for your time!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested