Question by
3dmihai · Sep 01, 2016 at 08:19 AM ·
scenescenesload scene
Can't switch to another scene using LoadSceneAsync()
Hi, I'm using triggers on different map positions to preload different scenes. There's a second type of triggers that actually switch to the new scene, depending on their corresponding trigger. What happens is that when I go through 2 different triggers, 2 scenes are preloaded, but when i go to one final trigger to switch the scene, it doesn't activate it.
public static AsyncOperation async;
public void StartLoading()
{
StartCoroutine("load");
}
IEnumerator load()
{
Debug.LogWarning("Async load started... - " +
". . . . . . . . nu iesi din modu asta");
if (ScenesManager.weGoTo != null)
{
async = SceneManager.LoadSceneAsync(ScenesManager.weGoTo);
}
async.allowSceneActivation = false;
yield return async;
}
public static void ActivateScene()
{
Scene s = SceneManager.GetSceneByName(ScenesManager.weGoTo);
SceneManager.SetActiveScene(s);
async.allowSceneActivation = true;
}
The ActivateScene is static because I need to call it from a different script attached to another trigger, to actually switch to a new level. What could be wrong here?
Thank you.
scene-switch.png
(5.1 kB)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612091953im_/https://answers.unity.com/themes/thub/images/avi.jpg)