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

◆ AddFor()

static void Sisus.Init.ServiceUtility.AddFor ( [AllowNull] object serviceOrProvider,
[DisallowNull] Type definingType,
Clients clients,
[DisallowNull] Component registerer )
static

Sets the service instance of the provided definingType type that is shared across clients to the given value.

If the provided instance is not equal to the old Service<T>.Instance then the ServiceChanged<T>.listeners event will be raised.

Parameters
serviceOrProviderThe service instance to add.
definingTypeThe defining type of the service; the class or interface type that uniquely defines the service and can be used to retrieve an instance of it.

This must be an interface that the service implement, a base type that the service derives from, or the exact type of the service.

Parameters
clientsSpecifies which client objects can receive the service instance in their Init function during their initialization.
registererComponent that is registering the service. This can also be the service itself, if it is a component.

This same argument should be passed when removing the instance.