While + yield Vs Update

You can’t coroutine an Update, but you could coroutine this:


//put whatever code you need here 


why in the world would you ever want to use an update, they seem to be essentially the same.

is there anything you can’t do with while true yield that you can with update?

just wondering is all


The way I look at it Update is a convenience for when you need a closed loop so you don’t have to do what you outlined above. There’s a lot of times when you want infinite loops that last for the games entire execution. For example receiving user input.

The only reason I can really think of is its ease of use to novice programmers. When you’re still having issues with basic syntax, the concept of coroutines can be pretty baffling, having something you vaguely know does something “at all times” is quite nice. Another reason would be that Update only gets called if the component and gameObject are active, which can be handy in some situations as well.
while {yield;} is often better because it gives you more control and even the documentation says so. So, again, my guess is that it’s mostly for an easier start to coding, especially because by default scripts contain Update().