Scripting Reference

◆ Init() [1/5]

abstract void Sisus.Init.MonoBehaviour< TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument >.Init ( TArgument  argument)
protectedpure virtual

Provides the Component with the argument object that it depends on.

You can think of the Init function as a parameterized constructor alternative for the component.

Init get called when the script is being loaded, before the OnAwake, OnEnable and Start events when the component is created using ObjectExtensions.Instantiate<TArgument> or GameObject.AddComponent{TComponent, TArgument}.

In edit mode Init can also get called during the Reset event when the script is added to a GameObject, if the component has the InitOnResetAttribute or RequireComponent attribute for each argument.

Note that Init gets called immediately following object creation even if the GameObject to which the component was added is inactive unlike some other initialization event functions such as Awake and OnEnable.

argumentobject that this Component depends on.

Implements Sisus.Init.IInitializable< TFirstArgument, TSecondArgument, TThirdArgument, TFourthArgument, TFifthArgument >.