diff --git a/Counters+/Installers/CountersInstaller.cs b/Counters+/Installers/CountersInstaller.cs index 175000d..f0f9ded 100644 --- a/Counters+/Installers/CountersInstaller.cs +++ b/Counters+/Installers/CountersInstaller.cs @@ -95,7 +95,7 @@ protected void AddCounter(Func additionalReasonToSpawn) where T : Plugin.Logger.Debug($"Loading counter {settings.DisplayName}..."); - if (typeof(R).BaseType == typeof(MonoBehaviour)) + if (typeof(MonoBehaviour).IsAssignableFrom(typeof(R))) { Container.BindInterfacesAndSelfTo().FromNewComponentOnRoot().AsSingle().NonLazy(); } @@ -117,7 +117,7 @@ protected void AddCustomCounter(CustomCounter customCounter, Type counterType) Plugin.Logger.Debug($"Loading counter {customCounter.Name}..."); - if (counterType.BaseType == typeof(MonoBehaviour)) + if (typeof(MonoBehaviour).IsAssignableFrom(counterType)) { Container.BindInterfacesAndSelfTo(counterType).FromNewComponentOnRoot().AsSingle().NonLazy(); } diff --git a/Counters+/Installers/MenuUIInstaller.cs b/Counters+/Installers/MenuUIInstaller.cs index 187d514..5b0f39e 100644 --- a/Counters+/Installers/MenuUIInstaller.cs +++ b/Counters+/Installers/MenuUIInstaller.cs @@ -30,9 +30,9 @@ public override void InstallBindings() if (customCounter.BSML != null && customCounter.BSML.HasType) { Type hostType = customCounter.BSML.HostType; - if (hostType.BaseType == typeof(MonoBehaviour)) + if (typeof(MonoBehaviour).IsAssignableFrom(hostType)) { - Container.Bind(hostType).WithId(customCounter.Name).FromComponentOnRoot().AsCached(); + Container.Bind(hostType).WithId(customCounter.Name).FromNewComponentOnNewGameObject().AsCached(); } else {