how can I use yield inside update function using c# ???
It’s not possible. Don’t use Update, use coroutines. unifycommunity.com - unifycommunity Resources and Information.
–Eric
Another way to put it would be… The update function is essentially a while (true) loop. It automatically yields, as it runs once every frame. It should be used for things you need to check every frame, not anything you’d require a yield for.
It’s real easy to work around this, though…
Just make another function, put the stuff you want to yield in that function, and call that function from Update.
You can yield in that function, if you want…
If you do that you’d be starting a new instance of the coroutine every frame from Update, unless you use more logic to prevent that. Really, it’s best just to not use Update at all in situations like this, it only makes things more complicated.
–Eric
Actually, therre is a solution. You can create an update function that supports yield statements. Check out this Unity wiki page: http://www.unifycommunity.com/wiki/index.php?title=CoUpdate
Yes, that’s the same link I posted in my first reply.
–Eric