Loading screen - Wait for script bool to be true before showing the scene?

Hi. What I’m wondering about is how can I make a loading screen that waits until a script from the scene being ‘loaded’ is bool true?

I have a public bool called worldGenHasFinished(), that when it’s set to true it has finished loading the terrain.

How do I make it like this pattern:
MainMenu scene > Loading scene (wait until worldGenHasFinished from world scene) > Load the world scene.

Please let me know if there’s anything more you’d like to know or if you misunderstood anything, then I’ll try and explain further.

Have you tried using a coroutine?

import UnityEngine.SceneManagement; // must use this in script


function WaitForNewScene(){

while(yourScript.worldGenHasFinished != true ){  yield;}
  worldGenHasFinished = true;
  SceneManager.LoadScene(nextWorld);
}