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

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

static void Sisus.Init.Create.Instance< TScriptableObject, TArgument > ( out TScriptableObject instance,
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 dependencies into readonly fields.

Template Parameters
TScriptableObjectType of the ScriptableObject to create.
Parameters
instanceWhen this method returns, contains the scriptable object of type TScriptableObject that was created. This parameter is passed uninitialized.
argumentThe object that the created ScriptableObject depends on.
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>