I've been following the tutorial on changing scenes asynchronally (as seen here) and translating it to C#, however, the following errors occur:
- E 0:00:01.799 get_tree: Condition "!data.tree" is true. Returned: nullptr
- E 0:00:01.802 connectsignalawaiter: Parameter "p_source" is null.
When yielding, I run
await (ToSignal(GetTree(), "idle_frame"));
as seen here
however the errors above happen right at that moment. What am I missing to properly load resources/scenes asynchronously?
Code:
private async void ChangeSceneAsync(string path)
{
ResourceInteractiveLoader ril = ResourceLoader.LoadInteractive(path);
while (true)
{
Error err = ril.Poll();
if (err == Error.FileEof)
{
Resource res = ril.GetResource();
break;
}
if (err == Error.Ok)
{
float progress = (float)(ril.GetStage() / ril.GetStageCount());
GD.Print(progress);
}
await (ToSignal(GetTree(), "idle_frame")); // Errors occur here
}
}