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

◆ Instance< TScriptableObject, TArgument >() [1/2]

static TScriptableObject Sisus.Init.Create.Instance< TScriptableObject, TArgument > ( TArgument argument)
static

Creates an instance of ScriptableObject of type TScriptableObject and initializes it with the provided argument .

For classes that derive from ScriptableObject<TArgument> IInitializable<TArgument>.Init gets called at the beginning of the Awake event.

For classes that implement IInitializable<TArgument> IInitializable<TArgument>.Init is called at the end of initialization, after Awake and OnEnable but before Start.

Classes that implement IArgs<TArgument> can also manually acquire the dependency using the InitArgs.TryGet<TClient, TArgument> function during any stage of initialization, including the constructor - in which case it is even possible to assign the dependency into a readonly field.

Template Parameters
TScriptableObjectType of the ScriptableObject to create.
Parameters
argumentThe object that the created ScriptableObject depends on.
Returns
The created ScriptableObject instance.
Exceptions
InitArgumentsNotReceivedExceptionThrown if TScriptableObject class does not implement IInitializable<TArgument> and did not manually handle receiving the provided arguments.
Type Constraints
TScriptableObject :ScriptableObject 
TScriptableObject :IArgs<TArgument>