Coroutines: Inactive objects#

Coroutine couldn't be started because the the game object 'X' is inactive!

Coroutines can only be run on active GameObjects.


Check that the GameObject is active before you start the coroutine#

Use activeInHierarchy to check whether the GameObject is active. Don't use activeSelf, the GameObject's active state depends on the hierarchy.

if (gameObject.activeInHierarchy)


Start the coroutine on another object that is active#

Reference another component that is in an active hierarchy and start the coroutine on it instead.