Can I access a MonoBehavior...[CLOSED]

Post deleted by user.

All MonoBheaviours are Behaviours but not all Behaviours are MonoBehaviours. A camera is not a MonoBehaviour. You cannot make it run a coroutine because it does not have the ability to run a coroutine, because it is not a MonoBehaviour. Sometimes Behaviours are MonoBehaviours, and you can cast from Behaviour to MonoBehaviour and use methods from MonoBehaviour, but in the case of Camera, that is not the case.

Either use a singleton “Coroutine Runner” MonoBehaviour, or attach another MonoBehaviour to the main camera GameObject (some other script of your own) and use GetComponent to fetch it (you can cache this similarly to how you’re caching Camera.main), or pass in a MonoBehaviour to your script.

1 Like