- Home /
The question is answered, right answer was accepted
Why isn't my scene transition coroutine working?
This is the coroutine:
public void LoadScene (string levelName)
{
StartCoroutine(TransitionAndLoad(levelName));
}
private IEnumerator TransitionAndLoad (string levelName)
{
leftPanel.SetTrigger("exit");
rightPanel.SetTrigger("exit");
Time.timeScale = 1;
yield return new WaitForSeconds(30);
if (levelCompleted)
{
GameManager.Instance.Save();
}
SceneManager.LoadScene(levelName);
}
It works on every scene but the Main Menu. Why is it not working? I always access it the same way: by pressing a button. This doesn't make any sense! It should totally work. I've checked the code of my menu scripts and nothing seems to be interfering with this. Help, please?
This is how it behaves on the main menu: it sets the triggers, freezes and just loads the level. No transition at all.
Thanks in advance.
Answer by Igor_Vasiak · May 03, 2018 at 07:45 PM
Nevermind, I found a solution. It was, indeed, a script interfering with it, adding a listener to the button. I had thrown away the possibility of a script interfering with my button because I already searched the scripts and it turned out that I didn't find anything at all. But I may be blind or something like that, because the faulty line of code was right in sight and isolated, so I should have seen it before,as it could have saved me some hours trying to fix this. :p
My bad...
Follow this Question
Related Questions
Unity keep crashing when loading scene from a couritne (Unity 5.x) 1 Answer
Coroutine doesn't work when called from another method. 3 Answers
Unity tells me that WaitForSeconds() "does not contain a constructor that takes 1 argument" 0 Answers
Looping a Script 2 Answers
Problem with coroutine 2 Answers