- Home /
Can anyone link to / explain Unity's game loop?
Hopefully this is an easy enough question, but as a programmer I'm always wondering what Unity is actually doing behind the scenes. While reading through the API references, and just by trial-and-error, I'd guess the loop goes something like this:
Instantiate new objects
Call Update on all objects/components
Do Physics (I'm sure there are a ton of substeps, like Fixed Updates and collision events, but I don't have a clue how they are integrated)
Destroy requested objects
Render everything according to scene graph (like physics, I have no clue what the internals of this are)
Call OnGUI on all objects/components
Flip screen buffer, loop.
Thanks for any insight you guys can give me on this!
Those are very large. That's why I asked for a link to it, because I haven't been able to find it thus far.
Answer by whydoidoit · Feb 16, 2014 at 05:08 AM
Sure it looks like this:
Destroyed objects happen at the very end of all of that (unless of course you use DestroyImmediate).
Full article (which is about where the coroutines run): http://unitygems.com/coroutines
Thanks! I think I might just print this and tape it to my wall.