Skip to content

Commit af43b24

Browse files
committed
fix: some other stuffs
1 parent b43c49b commit af43b24

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

Scripts/Runtime/Core/ISOCItem.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ public interface ISOCItem
99
string name { get; set; }
1010
void SetCollection(ScriptableObjectCollection collection);
1111
void GenerateNewGUID();
12+
void ClearCollection();
1213
}
1314

1415
public interface ISOCColorizedItem
1516
{
1617
Color LabelColor { get;}
1718
}
18-
}
19+
}

Scripts/Runtime/Core/ScriptableObjectCollection.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ public void Insert(int index, object value)
272272
public bool Remove(ScriptableObject item)
273273
{
274274
bool result = items.Remove(item);
275+
if (item is ISOCItem socItem)
276+
socItem.ClearCollection();
277+
275278
ObjectUtility.SetDirty(this);
276279
return result;
277280
}
@@ -360,13 +363,15 @@ public void RefreshCollection()
360363
changed = true;
361364
}
362365

363-
for (int i = items.Count - 1; i >= 0; i--)
366+
int itemsCount = items.Count;
367+
for (int i = itemsCount - 1; i >= 0; i--)
364368
{
365369
if (items[i] == null)
366370
{
367371
RemoveAt(i);
368372
Debug.Log($"Removing item at index {i} as it is null");
369373
changed = true;
374+
continue;
370375
}
371376

372377
ScriptableObject scriptableObject = items[i];

Scripts/Runtime/Core/ScriptableObjectCollectionItem.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public void SetCollection(ScriptableObjectCollection collection)
7979
public void ClearCollection()
8080
{
8181
cachedCollection = null;
82+
hasCachedCollection = false;
8283
collectionGUID = default;
8384
ObjectUtility.SetDirty(this);
8485
}

0 commit comments

Comments
 (0)