Init(args)
Scripting Reference
Loading...
Searching...
No Matches

◆ Awake()

virtual void Sisus.Init.Wrapper< TWrapped >.Awake ( )
protectedvirtual

Awake is called when the script instance is being loaded and handles calling the Init method with the TWrapped argument.

Awake is called either when an active GameObject that contains the script is initialized when a Scene loads, or when a previously inactive GameObject is set active, or after a GameObject created with Object.Instantiate is initialized.

Unity calls Awake only once during the lifetime of the script instance. A script's lifetime lasts until the Scene that contains it is unloaded. If the Scene is loaded again, Unity loads the script instance again, so Awake will be called again. If the Scene is loaded multiple times additively, Unity loads several script instances, so Awake will be called several times (once on each instance).

For active GameObjects placed in a Scene, Unity calls Awake after all active GameObjects in the Scene are initialized, so you can safely use methods such as GameObject.FindWithTag to query other GameObjects.

The order that Unity calls each GameObject's Awake (and by extension Awake) is not deterministic. Because of this, you should not rely on one GameObject's Awake being called before or after another (for example, you should not assume that a reference assigned by one GameObject's Awake will be usable in another GameObject's Awake). Instead, you should use Awake/Awake to set up references between scripts, and use Start, which is called after all Awake and Awake calls are finished, to pass any information back and forth.

Awake is always called before any Start functions. This allows you to order initialization of scripts. Awake is called even if the script is a disabled component of an active GameObject. Awake can not act as a coroutine.

Note: Use Awake instead of the constructor for initialization, as the serialized state of the Component is undefined at construction time.