Issue
When launching the game, a service does not get injected to any of its clients as expected, and an warning similar to the following can be seen in the Console window:
Invalid Service Definition: Class of the registered instance 'MyService' does not implement the defining interface type of the service 'IMyInterface'. UnityEngine.Debug:LogWarning (object) Sisus.Init.ServiceUtility:SetInstance (System.Type,object) (at Assets/Sisus/Init(args)/Scripts/Services/ServiceUtility.cs:278)
Solution
The problem seems to be that a class has the ServiceAttribute, with the defining type of the service set to an interface type, but the class does not implement the interface in question.
The class always needs to be assignable to the type passed to the ServiceAttribute constructor, otherwise it cannot be cast to that type and passed to clients as an Init method argument.
❌ Wrong
[Service(typeof(IMyInterface))] public class MyService : MonoBehaviour {
✅ Correct
[Service(typeof(IMyInterface))] public class MyService : MonoBehaviour, IMyInterface {