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

◆ InitTargetAsync()

System.Threading.Tasks.Task< object > Sisus.Init.IInitializer.InitTargetAsync ( )

Initializes the client object asynchronously with the arguments specified by this initializer.

The method will wait until all dependencies of the client are ready, and only then initialize the target. For example, if one of the dependencies is an addressable asset, the method can wait until the asset has finished loading, and then pass it to the client's Init method.

Note that if any dependency requires asynchronous loading, and the client is a component attached to an active scene object, then initialization event functions like Awake, OnEnable and Start can get called for the target before initialization has finished.

If Target is attached to the same GameObject as the initializer, then this method initializes the target and returns it.

If Target is attached to a different GameObject than the initializer, like for example a different prefab, then this method clones the target , initializes the clone, and returns it.

If Target is null, the initializer is a component, and the client is a component type, then a new component is attached to the GameObject containing the initializer, initialized, and returned.

This method should be idempotent, meaning that if it is called multiple times, it should always return an awaitable with the same result, the result object should only get initialized once.

Returns
The initialized object.

Implemented in Sisus.Init.IInitializer< TClient >.