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 the constructor of the [Service] attribute:
[Service(typeof(Logger), typeof(ILogger))]
class Logger : ILogger { }
Components that derive from MonoBehaviour<T…> will automatically receive a global service as an Init method argument, if the type of the argument matches one of the defining types of the service.
class ClientA : MonoBehaviour<ILogger>
{
protected override void Init(ILogger logger) => Debug.Log($"ClientA received {logger}.");
}
class ClientB : MonoBehaviour<Logger>
{
protected override void Init(Logger logger) => Debug.Log($"ClientB received {logger}.");
}