𝗙𝗶𝗿𝘀𝘁 𝗦𝗰𝗲𝗻𝗲 𝗹𝗼𝗮𝗱
𝙰𝚠𝚊𝚔𝚎: always called before any 𝚂𝚝𝚊𝚛𝚝 & after a prefab is instantiated
𝙾𝚗𝙴𝚗𝚊𝚋𝚕𝚎: called just after a 𝙶𝚊𝚖𝚎𝙾𝚋𝚓𝚎𝚌𝚝 is enabled (including when loaded, created, or a 𝙼𝚘𝚗𝚘𝙱𝚎𝚑𝚊𝚟𝚒𝚘𝚞𝚛 script is added)
-
-
Deze collectie tonen
-
𝗕𝗲𝗳𝗼𝗿𝗲 𝘁𝗵𝗲 𝗳𝗶𝗿𝘀𝘁 𝗳𝗿𝗮𝗺𝗲 𝘂𝗽𝗱𝗮𝘁𝗲
𝚂𝚝𝚊𝚛𝚝: called before the first frame update. This happens only if the script is enabled. 𝚂𝚝𝚊𝚛𝚝 can also be made into a coroutine by changing its return type to 𝙸𝙴𝚗𝚞𝚖𝚎𝚛𝚊𝚝𝚘𝚛Deze collectie tonen -
𝗣𝗵𝘆𝘀𝗶𝗰𝘀 𝗨𝗽𝗱𝗮𝘁𝗲
𝙵𝚒𝚡𝚎𝚍𝚄𝚙𝚍𝚊𝚝𝚎: often called several times during each frame. This is where the rigid bodies are updated.
This is also where you should call methods that *continuously* affect the physics, such as 𝙰𝚍𝚍𝙵𝚘𝚛𝚌𝚎 (when non-impulsive).Deze collectie tonen -
The physics event functions are invoked after each 𝙵𝚒𝚡𝚎𝚍𝚄𝚙𝚍𝚊𝚝𝚎 call:
𝙾𝚗𝚃𝚛𝚒𝚐𝚐𝚎𝚛𝚇𝚇𝚇
𝙾𝚗𝙲𝚘𝚕𝚕𝚒𝚜𝚒𝚘𝚗𝚇𝚇𝚇
They might be out-of-synch with the game logic. To fix this, you can use 𝚢𝚒𝚎𝚕𝚍 𝚆𝚊𝚒𝚝𝙵𝚘𝚛𝙵𝚒𝚡𝚎𝚍𝚄𝚙𝚍𝚊𝚝𝚎 in a coroutine.Deze collectie tonen -
𝗨𝗽𝗱𝗮𝘁𝗲 𝗢𝗿𝗱𝗲𝗿
𝚄𝚙𝚍𝚊𝚝𝚎: called once per frame on any active game object. This is where you want to put most of your game logic.
This is also where you should call one-time event input functions such as:
GetKeyDown
GetKeyUp
GetButtonDown
GetButtonUpDeze collectie tonen -
That is very confusing!
So this is a quick & overly simplified table to show you which methods should be safe to call from which event functions.
TL;DR:
One-time input events & game logic? ➔ 𝚄𝚙𝚍𝚊𝚝𝚎
Affecting physics over multiple frames? ➔ 𝙵𝚒𝚡𝚎𝚍𝚄𝚙𝚍𝚊𝚝𝚎pic.twitter.com/9mGbPz3nM9
Deze collectie tonen -
𝙻𝚊𝚝𝚎𝚄𝚙𝚍𝚊𝚝𝚎: called after *all* 𝚄𝚙𝚍𝚊𝚝𝚎 functions have been called.
It is pretty handy because you can assume that all game objects have been correctly updated.Deze collectie tonen -
𝗦𝗰𝗲𝗻𝗲 𝗥𝗲𝗻𝗱𝗲𝗿𝗶𝗻𝗴
𝙾𝚗𝚁𝚎𝚗𝚍𝚎𝚛𝙸𝚖𝚊𝚐𝚎: called after the scene rendering is complete. This is used to allow for post-processing.
A few years ago I wrote a tutorial about screen shaders, and how to use them for post-processing.https://www.alanzucconi.com/2015/07/08/screen-shaders-and-postprocessing-effects-in-unity3d/ …Deze collectie tonen -
There are many more event functions that are called before 𝙾𝚗𝚁𝚎𝚗𝚍𝚎𝚛𝙸𝚖𝚊𝚐𝚎, but those are rarely used. In case you are interested, they are:
OnWillRenderObject
OnPreCull
OnBecameVisible
OnBecameInvisibile
OnPreRender
OnRenderObject
OnPostRenderDeze collectie tonen -
𝗗𝗲𝗰𝗼𝗺𝗺𝗶𝘀𝘀𝗶𝗼𝗻𝗶𝗻𝗴
𝙾𝚗𝙳𝚒𝚜𝚊𝚋𝚕𝚎: this method mirrors the behaviour of 𝙾𝚗𝙴𝚗𝚊𝚋𝚕𝚎, being called when the 𝙼𝚘𝚗𝚘𝙱𝚎𝚑𝚊𝚟𝚒𝚘𝚞𝚛 becomes disabled or inactive.Deze collectie tonen -
There are many more methods I could simply not fit in this thread.
Most of the info comes from the official Unity documentation. You should definitely have a look at it if you are interested! 
https://docs.unity3d.com/Manual/ExecutionOrder.html …Deze collectie tonen -
𝒕𝒉𝒂𝒏𝒌 𝒚𝒐𝒖 𝒇𝒐𝒓 𝒄𝒐𝒎𝒊𝒏𝒈 𝒕𝒐 𝒎𝒚 𝒕𝒆𝒅 𝒕𝒂𝒍𝒌
I write about #gamedev, shader coding, programming & artificial intelligence.


If you are interested in any of those topics, follow me for more content like this!
https://www.patreon.com/AlanZucconi Deze collectie tonen
Einde van gesprek
Nieuw gesprek -
Het laden lijkt wat langer te duren.
Twitter is mogelijk overbelast of ondervindt een tijdelijke onderbreking. Probeer het opnieuw of bekijk de Twitter-status voor meer informatie.
