- Home /
Coroutine works in editor, but not in build Windows application
My Coroutine work in the Editor in the "Play mode", but not in build application. So, I have Coroutine in my project:
IEnumerator Scream()
{
Screamer.GetComponent<Screamer>().makeActive();
yield return new WaitForSeconds(3);
Application.LoadLevel(Application.loadedLevel);
}
I call Coroutine from Update() function:
void Update () {
...
if (...)
{
StartCoroutine(Scream());
}
}
In Editor (I have Unity 5.3.1f1 Personal) everything works fine, so I can't imagine, what can be wrong here.
Thank you in advance.
UPDATE: Everything else works fine.
Are you sure your if is triggered on your device? What's the condition?
Good Point do something in that if that you can miss to find out if its trigger at all (Debug.Log("For example");.
Agree with adding some logging. But seeing as that's only going to be of use if you check the log, it might be worth doing that first. If you've already done that and seen nothing that looks relevant then that's information that should be in the question.
Also, we have the "doesn't work" doesn't tell us much problem here. Please describe fully. For example, is it that none of the lines in the CR appear to run? Or is it that (for example) the first line appears to run but not the subsequent lines.
I have pretty complex "if" settlement with multiple triggers. To be sure, I changed it to simple timer:
timeLeft -= Time.deltaTime;
Debug.Log(timeLeft);
if (timeLeft < 0)
{
StartCoroutine(Scream());
}
And still the same: In Editor Coroutine starts, in Windows application — not.
How do you know it doesn't start? Is the call to StartCoroutine happening? Is the Debug.Log showing that timeLeft drops below zero ?
I know this post is very old, but did you find a solution? I have exactly the same problem.
First of all, your "answer" wasn't an answer, so I have converted it to a comment.
Second, you're better off posting a new question rather than tagging onto this one. Your situation isn't going to be exactly the same because your code will be different. So in your question, show us your code. Let us know what you've done to investigate the problem (eg looking at the logs).
Note that in the OP's situation it turned out that their CR was starting, and then something was going wrong. I gave up on them because they seemed to expect us to be $$anonymous$$d-readers. "Something not working" is just not going to help. It's up to you to investigate what's not working, we can only point in certain directions.
Generally speaking - you need to use the logs if debugging a build. Add Debug.Log calls. If the logs show a Null or $$anonymous$$issing Reference exception, then if the log doesn't hel you work out what's missing then you need to add stuff to catch the null and tell you what it is.
So do some investigation and then if the problem persists, start a new question showing your code and showing what errors if any the log throws up.
Hi, it turns out I kept looking, and my problem turned out to be using WaitForEndOfFrame, and it turns out that this "function" doesn't run on builds. I'm sorry for my English.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Startcoroutine not working second time 2 Answers
Issues with my loading screen 0 Answers
Second Coroutine isn't working Unity 1 Answer
Coroutines randomly stop working 0 Answers