From fba81803503ec2adf7790dee681b2aae3cb69c96 Mon Sep 17 00:00:00 2001 From: Bruno Mikoski Date: Mon, 4 Sep 2023 10:20:05 +0100 Subject: [PATCH] fix: implementation --- Scripts/Runtime/Core/CollectionsRegistry.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Scripts/Runtime/Core/CollectionsRegistry.cs b/Scripts/Runtime/Core/CollectionsRegistry.cs index b3bb93d..5ffe1b0 100644 --- a/Scripts/Runtime/Core/CollectionsRegistry.cs +++ b/Scripts/Runtime/Core/CollectionsRegistry.cs @@ -170,13 +170,15 @@ public bool TryGetCollectionsOfItemType(out List(out List inputActionMapCollections) where T : ScriptableObjectCollection + public bool TryGetCollectionsOfType(out List inputActionMapCollections, bool allowSubclasses = true) where T : ScriptableObjectCollection { List result = new List(); + Type targetType = typeof(T); for (int i = 0; i < collections.Count; i++) { ScriptableObjectCollection scriptableObjectCollection = collections[i]; - if (scriptableObjectCollection.GetType() == typeof(T) || scriptableObjectCollection.GetType().IsSubclassOf(typeof(T))) + Type collectionType = scriptableObjectCollection.GetType(); + if (collectionType == targetType || (allowSubclasses && collectionType.IsSubclassOf(targetType))) result.Add((T)scriptableObjectCollection); }