Problem: You have a base class that depends on some services. You want to create a class that derives from that base class, which depends on some additional services on top of the ones that the base class does. class Base : MonoBehaviour<A, B> { // The base class depends on some services A a; ..
Author : Timo Naskali
Represents an object that can provide values of requested types on demand. A scriptable object or component that implements the IValueByTypeProvider interface can be assigned to an Initializer field, if IValueByTypeProvider.CanProvideValue returns true when provided the type of the field and a reference to the initializer. During initialization the Initializer will request the Init argument ..
Issue Init(args) only supports passing a maximum of twelve arguments to a component that derives from MonoBehaviour<T…> or implements IInitializable<T…> during its initialization. What can you do if you have a legacy class that depends on more than twelve external objects, and you want to refactor the class to derive from MonoBehaviour<T…> and receive those ..
When you register a global or a local service, you will always have to specify – either implicitly or explicitly – one or more defining types for it. In the below example, the Logger class is configured to be a global service with the defining types Logger and ILogger, by explicitly specifying the types in ..
Services Component The Services component can be used to register multiple asset and scene based services accessible to select clients. Registering Services Using The Services Component You can attach the Services component to any GameObject using the Add Component menu. Assigning Services Add a new item to the Provides Services list. Drag-and-drop the Object you ..
Service Tag In addition to global services – which are guaranteed to be available to all clients for the entire lifetime of the application – it is also possible to register local services using Service Tags. Local services live as part of scene or prefab assets, and are only available to clients for as long ..
Services that can automatically be delivered to clients by Init(args) can be split into two groups based on their availability: local and global services. A local service is a service that is only available to select clients, depending on their location in the scene hierarchies. Unlike global services, local services only exist for a limited ..
Services that can automatically be delivered to clients by Init(args) can be split into two groups based on their availability: global and local services. A global service is a service that is available to all clients, regardless of their location in the scene hierarchies. Registering Global Services The main way to register global services is ..
The [ValueProviderMenu] attribute can be used to introduce new menu items that will be shown in the dropdown menus for all Init arguments of targeted types. The attribute can be added to a ScriptableObject-derived class that implements IValueProvider<TValue> or IValueByTypeProvider. You can then use the Value property to access the value stored inside the field. ..
Add this attribute to a component to have the arguments accepted by it be automatically gathered and passed to its Init function in Edit Mode, whenever any objects in the same scene or prefab that contains the component are modified. This attribute supports any components that implement IInitializable<T>, which includes all classes that derive from ..