- Home /
"Coroutine couldn't be started..." warning - harmless?
You've probably had this situation: you have an object (perhaps a button for example)
You have some minor behaviour attached below it (say, a repetitive glow on the button)
As you enter the scene, you make the whole object inactive.
Now, this means you'll get the alert
"Coroutine couldn't be started because the the game object ''exampleGlow'' is inactive! UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator)"
In fact ........... is this warning harmless?
I usually go through and fix these so you don't get the warning, but I've often shipped with a few of those. In fact is it harmless? (I've never seen any harm come, but someone may have more info.)
Cheers
Answer by Tarlius · Feb 25, 2013 at 07:53 AM
Well, it depends what the coroutine it couldn't start does! If its a button glow you probably won't care, but if its something that tracks a game objective and fails to start... well, your game is broken.
I normally check whether the game object is active or not before I try starting a coroutine on an object that I expect might get turned off, because for some reason it errors for me, not warning... Might be a platform dependant thing?
thanks, I need specific information whether that message thrown by Unity results in Unity stopping or not. I mean when running on a final device in a consumer's hands.
When you say it errors for you, what platform is that on man, what device?
thanks for that ..
I just ran a simple test with the following code, with iOS as build target in the editor:
void Awake() {
this.gameObject.active = false;
StartCoroutine(testCoroutine());
this.gameObject.active = true;
Debug.LogWarning("Continued");
}
IEnumerator testCoroutine() {
while(true) {
Debug.Log("Running");
yield return null;
}
}
Continued was printed on the log, Running was not. I always thought it was an exception, but its only an error log. The rest of the routine will run as normal, but the point that the coroutine won't fire stands. So whether the error is "harmless" or not depends what logic you're failing to launch.
O$$anonymous$$ I completely understand that in terms of my own code, the code must work :-) I was asking about whether it throws some sort of problem from Unity's pov, when in the consumer's hands.
I feel you have in fact nicely proved that there is no problem, it's only a dumb error $$anonymous$$ESSAG$$anonymous$$
I really appreciate this and this is a great answer. Thanks.
Your answer
Follow this Question
Related Questions
Waiting for a coroutine to complete before getting a return value 1 Answer
Delay Jump 1 Answer
Coroutine not running 1 Answer
Yield return inside a loop slowdown problem 2 Answers
WaitUntil doesn't work and the coroutine starts anyways 1 Answer