c# – Unity animation doesn’t play after transitioning to a new scene
I would like to play an animation before switching to a new scene, load the scene and then play another animation after that. The code I use for this task is as follows:
IEnumerator PlayTransitionAndLoadSceneCoro(string sceneName) {
transition.SetTrigger("Start");
yield return new WaitForSeconds(transitionTime);
AsyncOperation asyncSceneLoad = SceneManager.LoadSceneAsync(sceneName);
while (!asyncSceneLoad.isDone)
yield return null; // Block execution until the scene is loaded
transition.SetTrigger("End");
}
Both scenes use the same TransitionManager prefab, and my animator object is set up as follows:
But while the animation plays properly in the first scene, it doesn’t play on the new scene (that also has the TransitionManager prefab) as shown in the gif below.
Read more here: Source link