it
UnityEngine.SceneManagement.SceneManager.LoadScene("Gameplay");
and yes, he does it “instantly,” that is, s ynchronously.
In other words, it “stops” on this line of code, waits until it loads the entire scene (even if it takes a few seconds), and then a new scene begins.
Do not use the old command specified in the question.
Please note that Unity also has the ability to sync a . She slowly loads a new scene in the background.
However: I recommend you use the usual "LoadScene". All that matters is reliability and simplicity. Users simply don't mind if the car just “stops” for a few seconds while the level is loading.
(Each time I press "Netflix" on my TV, it takes some time for the TV. Nobody cares - that's fine.)
But if you want to download in the background, here's how ...
public void LaunchGameRunWith(string levelCode, int stars, int diamonds) { .. analytics StartCoroutine(_game( levelCode, superBombs, hearts)); } private IEnumerator _game(string levelFileName, int stars, int diamonds) { // first, add some fake delay so it looks impressive on // ordinary modern machines made after 1960 yield return new WaitForSeconds(1.5f); AsyncOperation ao; ao = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync("Gameplay"); // here exactly how you wait for it to load: while (!ao.isDone) { Debug.Log("loading " +ao.progress.ToString("n2")); yield return null; } // here a confusing issue. in the new scene you have to have // some sort of script that controls things, perhaps "NewLap" NewLap newLap = Object.FindObjectOfType< NewLap >(); Gameplay gameplay = Object.FindObjectOfType<Gameplay>(); // this is precisely how you conceptually pass info from // say your "main menu scene" to "actual gameplay"... newLap.StarLevel = stars; newLap.DiamondTime = diamonds; newLap.ActuallyBeginRunWithLevel(levelFileName); }
Note: the script answers the question of how you transmit information "from your main menu" when a player clicks "play" on the real game scene. "
Fatie source share