DEV Community

KENTO⚽️XR Engineer😎
KENTO⚽️XR Engineer😎

Posted on

【Unity】Can you explain whether Awake or Start is called when a Gameobject is activated?

Four years have passed since I started to use Unity, but I have misunderstood about the title.

Basically, Awake and Start are UnityEvent Function called when a Gameobject is activated.

But, how about are the below situations?

A Gameobject is active, a component is disable.

In this case, only Awake is called.

Image description

A Gameobject is inactive, a component is enable.

In this case, nothing is called.
Image description

Switch a Gameobject in the order of active, inactive, and active.

In this case, Awake and Start are called only once.

Image description

If you want to call something when a Gameobject's active changes, you can use OnEnable which is UnityEvent Function.

Other Resources

Order of execution for event functions

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay