Hi guys, quick question
if I:
- instantiate gameObject
- the attached script’s Awake function will run
- i decide to gameObject.SetActive(false)
- 5 seconds pass
- i then gameObject.SetActive(true)
will the Awake function run again?
thanks!
Hi guys, quick question
if I:
will the Awake function run again?
thanks!
No, Awake() is only called once on an object.
OnEnable is called every time it is activated, though.
i was doing a lot of get component calls in the on Awake and was worried it would be running it again every time i setActive(true)
thanks for clearing it up
As a side note, you could try to use a debug.log command to see if your Awake method is called many times
Not that I’m not saying you shouldn’t ask here (don’t get me wrong), but instead I am just letting you know, in case you never used it.
It is really handy when you want to debug your script…
Debug.Log("insert your message here");
yea sorry, thanks for the tip.
just posted whilst on the bus