![]() |
Init(args)
Scripting Reference
|
A base class for an initializer that can be used to specify the two arguments used to initialize a scriptable object that implements IInitializable<TFirstArgument, TSecondArgument>.
The arguments can be assigned using the inspector and are serialized as a sub-asset of the client scriptable object.
The arguments get injected to the TClient client during the client's Awake event, or when services become ready (whichever occurs later).
The client receives the arguments via the Init method where it can assign them to member fields and properties.
When you derive your initializer class from ScriptableObjectInitializerBase<,,> you are responsible for implementing the argument properties and serializing their values. This means you will need to write a little bit more code, but it also grants you more options in how to handle the serialization, making it possible to support types that Unity can't serialize automatically. If you derive from ScriptableObjectInitializer<,,> instead, then these things will be handled for you.
TClient | Type of the initialized scriptable object. |
TFirstArgument | Type of the first argument to pass to the client's Init function. |
TSecondArgument | Type of the second argument to pass to the client's Init function. |
TClient | : | ScriptableObject | |
TClient | : | IInitializable | |
TClient | : | TFirstArgument | |
TClient | : | TSecondArgument |
Protected Member Functions | |
override TClient | InitTarget ([AllowNull] TClient target) |
virtual void | OnReset (ref TFirstArgument firstArgument, ref TSecondArgument secondArgument) |
Resets the Init arguments to their default values. | |
Properties | |
TFirstArgument | FirstArgument [get, set] |
The first argument passed to the TClient client's Init function. | |
TSecondArgument | SecondArgument [get, set] |
The second argument passed to the TClient client's Init function. | |
![]() | |
Object | Target [get, set] |
Existing target instance to initialize, if any. | |
bool | ProvidesCustomInitArguments [get] |
Gets a value indicating whether this initializer is able to provide custom per-instance Init arguments for its client. | |
Additional Inherited Members | |
![]() | |
new TClient | InitTarget () |
Initializes the client object of type TClient with the arguments specified by this initializer. | |
new System.Threading.Tasks.Task< TClient > | InitTargetAsync () |
Initializes the client object of type TClient asynchronously with the arguments specified by this initializer. | |
![]() | |
bool | TargetIsAssignableOrConvertibleToType (Type type) |
Gets a value indicating whether an object of the given type can be assigned to the Target property directly, or if type implements IValueProvider<T>, IValueByTypeProvider or IValueByTypeProviderAsync. | |