- Home /
Tasks with Coroutines don't work properly on play mode
Hi all!!
I have been some time with this problem now and haven't seen an answer to my problem on the internet and that is why I have finally come here.
So, I have a code that basically calls a coroutine inside a task from Firebase (I don't know if this is relevant). Something like this:
FirebaseReference.GetValueAsync().ContinueWith(task =>
{
MyFunction();
});
MyFunction()
{
StartCoroutine (Coroutine());
}
IEnumerator Coroutine()
{
// Do something (change a text for example)
yield return 0;
}
And when I try on play mode nothing fails, it just doesn't work, but it does work if I build it.
Thanks in advance. Have a great day!
Answer by Casiell · Oct 28, 2019 at 11:07 AM
Coroutines do not work in edit mode, only in play mode (and in build of course).
This thread seems like it has some solutions that could make it work
Sorry, I meant on play mode, not edit mode. I edited the question.
Answer by liuyi1 · Mar 13, 2020 at 11:05 AM
Yeah, i have been meeting exactly the same problem as @kaosermail using firebase.
This problem behaves like that I marked some break point in function of Coroutine for debuging and I put this testing code in entry of Game and started playing game, but there was very few opportunities to trigger this break point, which is about one time triggered when i started my game for 20~30 times.It made a quite hassle for my debug.
And I have also done some test of this problem On my Android Phone with some debug log, I found those log very easy in Android Studio Console every time I started my game. So I doubt this Coroutine can not work properly only in Editor.
Look at this Article “link text” , I think it may be caused by thread.