- Home /
The question is answered, right answer was accepted
Coroutine only starts when directly loading a scene from Unity editor.
Hi,
I have a character selection screen that displays a confirmation screen and when selecting, a coroutine is started, a burst of particles fly into the screen and the new level is loaded - this is to delay the loading of the level so the particles can fill the screen.
This all works as intended when I test it by directly loading the scene (character selection) on the Unity editor, however, if I'm doing a full test and I come from (Start Screen) I can do everything and the debug says it is registering everything, however the particles don't show up and the loading doesn't execute.
Also, the console doesn't display any errors.
I've tried everything (Stop coroutine, using a while(true)...) but can't figure out why it doesn't load. Code below:
IEnumerator DelayLoad() {
heartExplosion[explosionNumber].gameObject.SetActive(true);
yield return new WaitForSeconds(1);
SceneManager.LoadScene(sceneName);
}
public void LoadEloise() {
sceneName = "Eloise"; //selects the character and therefore which new scene will be loaded
explosionNumber = 10; //selects the particle system that corresponds to that character
StartCoroutine(DelayLoad());
}
The UI button has LoadEloise() as the method that gets triggered when clicking on it.
This is a video showing what happens when testing from the screen the coroutine is hosted: https://www.youtube.com/watch?v=BQAgzJ-HJB4&feature=youtu.be
And this is what happens when reaching the same part from the previous scene: https://www.youtube.com/watch?v=WhEzi9Qjvg8&feature=youtu.be
Thanks a lot!
The fact that there's no errors seems like LoadEloise()
isn't being called in the first place. Try testing On$$anonymous$$ouseDown()
on a button to call LoadEloise()
Thanks $$anonymous$$agso, it does work when testing from the scene where the coroutine is hosted, but not when reaching that same part starting from the previous scene.
I have made two videos showing what it looks like when starting from the Character Select screen and when starting from the previous one.
Character select screen: https://www.youtube.com/watch?v=BQAgzJ-HJB4&feature=youtu.be
When starting from the previous screen (start screen) https://www.youtube.com/watch?v=WhEzi9Qjvg8&feature=youtu.be
Answer by NeoCroMagnon · Jun 12, 2019 at 09:42 PM
Managed to find the issue, it had nothing to do with that part of the code but with a line coming from a library that I was using on the previous scene and forgot about and which changed the time settings of the project.