Skip to content

Commit 8a69127

Browse files
committed
fix: using direct AssetDatabase.Find
1 parent 5831213 commit 8a69127

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed

CHANGELOG.MD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased]
88
## Changed
99
- Update PickerPropertyDrawer to use PopupList from property path cache to avoid issue when rendered inside a List/Array
10+
- Update CollectionRegistry to search for the ScriptableObjectCollection using the `AssetDatabase.FindAssets` instead of the `TypeCache` first
1011

1112
## [2.3.3]
1213
## Added

Scripts/Runtime/Core/CollectionsRegistry.cs

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -329,30 +329,25 @@ public void ReloadCollections()
329329
List<ScriptableObjectCollection> foundCollections = new List<ScriptableObjectCollection>();
330330

331331
bool changed = false;
332-
TypeCache.TypeCollection types = TypeCache.GetTypesDerivedFrom<ScriptableObjectCollection>();
333-
for (int i = 0; i < types.Count; i++)
332+
string[] typeGUIDs = AssetDatabase.FindAssets($"t:{nameof(ScriptableObjectCollection)}");
333+
334+
for (int j = 0; j < typeGUIDs.Length; j++)
334335
{
335-
Type type = types[i];
336-
string[] typeGUIDs = AssetDatabase.FindAssets($"t:{type.Name}");
336+
string typeGUID = typeGUIDs[j];
337+
ScriptableObjectCollection collection =
338+
AssetDatabase.LoadAssetAtPath<ScriptableObjectCollection>(AssetDatabase.GUIDToAssetPath(typeGUID));
337339

338-
for (int j = 0; j < typeGUIDs.Length; j++)
339-
{
340-
string typeGUID = typeGUIDs[j];
341-
ScriptableObjectCollection collection =
342-
AssetDatabase.LoadAssetAtPath<ScriptableObjectCollection>(AssetDatabase.GUIDToAssetPath(typeGUID));
340+
if (collection == null)
341+
continue;
343342

344-
if (collection == null)
345-
continue;
343+
if (foundCollections.Contains(collection))
344+
continue;
346345

347-
if (foundCollections.Contains(collection))
348-
continue;
346+
if (!collections.Contains(collection))
347+
changed = true;
349348

350-
if (!collections.Contains(collection))
351-
changed = true;
352-
353-
collection.RefreshCollection();
354-
foundCollections.Add(collection);
355-
}
349+
collection.RefreshCollection();
350+
foundCollections.Add(collection);
356351
}
357352

358353
if (changed)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.brunomikoski.scriptableobjectcollection",
33
"displayName": "Scriptable Object Collection",
4-
"version": "2.3.3",
4+
"version": "2.3.4",
55
"unity": "2022.2",
66
"description": "A library to help improve the usability of Unity3D Scriptable Objects by grouping them into a collection and exposing them by code or nice inspectors!",
77
"keywords": [

0 commit comments

Comments
 (0)