- Home /
Updating text while loading a scene (async)
Hi guys,
I'm trying to load a scene and updating the loading text while things are going on in the new scene (I'm generating a procedural world for the player).
In scene 1 (the main menu) I have a Text object on a panel that I show when I launch it from a menu the user selected. This loads the new scene with something like this:
public void LoadScene(int scene)
{
StartCoroutine(LoadNewScene(scene));
}
IEnumerator LoadNewScene(int scene)
{
var async = SceneManager.LoadSceneAsync(scene);
while (!async.isDone)
{
Debug.Log("Loading " + async.progress);
yield return null;
}
}
This is fine and loads the scene but from within the new scene I'm trying to get at the Text object in the first scene to update the text as the world builds.
I'm thinking need some kind of Singleton to shuffle the text between the old scene (and update the Text component with it) and setting it from the new scene but not sure if that would work (e.g. inside the async loop for example).
Thanks
Your answer
Follow this Question
Related Questions
How to use AsyncOperation.completed? 1 Answer
Two async operations at the same time not working ? why ? 0 Answers
AsyncOperation.allowSceneActivation is actually static? 0 Answers
MissingReferenceException on Inspector-assigned values after reloading scene 1 Answer
Holding SceneManager.LoadSceneAsync until a button has been pressed? 1 Answer