Skip to content

Commit

Permalink
Merge pull request #141 from qe201020335/binding_fix
Browse files Browse the repository at this point in the history
Fix MonoBehaviour custom counter menu binding
  • Loading branch information
NuggoDEV authored Aug 19, 2024
2 parents 3046bcf + df00bea commit 4623dbe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Counters+/Installers/CountersInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected void AddCounter<T, R>(Func<T, bool> additionalReasonToSpawn) where T :

Plugin.Logger.Debug($"Loading counter {settings.DisplayName}...");

if (typeof(R).BaseType == typeof(MonoBehaviour))
if (typeof(MonoBehaviour).IsAssignableFrom(typeof(R)))
{
Container.BindInterfacesAndSelfTo<R>().FromNewComponentOnRoot().AsSingle().NonLazy();
}
Expand All @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions Counters+/Installers/MenuUIInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 4623dbe

Please sign in to comment.