The Service class contains methods that can be used to manually register service objects and retrieve them for clients. This is lower level API. You typically don’t need to use it directly, but should instead use the [Service] attribute, Service Tag and Services component to register services, and create a class that derives from MonoBehaviour<T…> ..
Category : 08. Reference
The [Init] attribute can be added to MonoBehaviour<T…> derived types, or initializer types, to configure default settings related to initialization and the drawing of the Init section in the Inspector. using Sisus.Init; using UnityEngine; // Set Enabled to false, to disable NullArgumentGuard, hide the Init section in the Inspector, // and disable WaitForServices. This is ..
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 ..
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 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 ..
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 ..
Init(args) has been designed with inversion of control in mind and aims to make it as easy as possible to work with interfaces instead of specific classes in Unity. One pain point when using interfaces in Unity is that checking them for null can be problematic. This is because in addition to being actually null, ..
Represents an object that can provide a value of type TValue on demand. A scriptable object or component that implements the IValueProvider<TValue> interface can be assigned to an Initializer field of type TValue. During initialization the Initializer will request the Init argument from the value provider, and pass it to the client’s Init method. Example ..
Methods void Init(TFirstArgument firstArgument, … TwelfthArgument twelfthArgument); The Init method Classes that implement one of the generic IInitializable<T…> interfaces are called clients. Clients have an Init method through which they can receive up to twelve objects that they need during their initialization. using UnityEngine; using Sisus.Init; class Example : MonoBehaviour { void Start() => new ..