Skip to content

Commit 54fd1a5

Browse files
committed
fix: compilation
1 parent 97f1f3c commit 54fd1a5

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

Scripts/Runtime/CollectionsRegistry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public ScriptableObjectCollection GetCollectionByGUID(string guid)
9898
return null;
9999
}
100100

101-
public bool TryGetCollection<T>(out T resultCollection) where T: ScriptableObjectCollection
101+
public bool TryGetCollectionOfType<T>(out T resultCollection) where T: ScriptableObjectCollection
102102
{
103103
for (int i = 0; i < collections.Count; i++)
104104
{

Scripts/Runtime/ScriptableObjectCollection.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,18 @@ public static ScriptableObjectCollection<ObjectType> Values
401401
}
402402

403403
#if UNITY_EDITOR
404+
405+
public T GetOrAddNew<T>(string targetName = null) where T : ObjectType
406+
{
407+
if (!string.IsNullOrEmpty(targetName))
408+
{
409+
T item = Items.FirstOrDefault(o => o.name.Equals(targetName, StringComparison.Ordinal)) as T;
410+
if (item != null)
411+
return item;
412+
}
413+
414+
return (T) AddNew(typeof(T), targetName);
415+
}
404416

405417
public ObjectType GetOrAddNew(Type collectionType, string targetName)
406418
{
@@ -424,12 +436,12 @@ public ObjectType AddNew(string targetName)
424436
{
425437
return (ObjectType) AddNew(GetCollectionType(), targetName);
426438
}
427-
#endif
428439

429440
public ObjectType AddNew()
430441
{
431442
return (ObjectType)AddNew(GetCollectionType());
432443
}
444+
#endif
433445

434446
public ObjectType GetCollectableByGUID(string targetGUID)
435447
{

0 commit comments

Comments
 (0)