Skip to content

Commit 9f7b2c3

Browse files
committed
fix: item picker not allowing changes at runtime
1 parent 7f36e6b commit 9f7b2c3

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

CHANGELOG.MD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Fixed
1313
- `CollectionItemQueryPropertyDrawer.IsCombinationImpossible` no longer reports false positives for `Any` + `NotAny` and `All` + `NotAll` rule pairs. Impossibility for these now requires the stricter *subset* relationship between pickers (not just any intersection), matching the real-world satisfiability. `All` + `NotAny` continues to be flagged on any intersection, which is correct.
14+
- `CollectionItemPicker` and `CollectionItemIndirectReference<T>` now implement `ISerializationCallbackReceiver` to invalidate their runtime caches on deserialization, so inspector edits to a picker during Play Mode take effect immediately instead of returning the stale cached `Items`/`Ref`.
1415

1516
## [2.5.1] - 06/04/2026
1617
### Added

Scripts/Runtime/Core/CollectionItemIndirectReference.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public bool IsValid()
6767
}
6868

6969
[Serializable]
70-
public class CollectionItemIndirectReference<TObject> : CollectionItemIndirectReference
70+
public class CollectionItemIndirectReference<TObject> : CollectionItemIndirectReference, ISerializationCallbackReceiver
7171
where TObject : ScriptableObject, ISOCItem
7272
{
7373
[NonSerialized]
@@ -152,5 +152,15 @@ public void SetCollection(ScriptableObjectCollection targetCollection)
152152
collectionLastKnownName = targetCollection.name;
153153
#endif
154154
}
155+
156+
public void OnBeforeSerialize()
157+
{
158+
}
159+
160+
public void OnAfterDeserialize()
161+
{
162+
hasCachedRef = false;
163+
cachedRef = null;
164+
}
155165
}
156166
}

Scripts/Runtime/Core/CollectionItemPicker.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace BrunoMikoski.ScriptableObjectCollections.Picker
1111
/// work if the enum had the [Flags] attribute applied to it.
1212
/// </summary>
1313
[Serializable]
14-
public class CollectionItemPicker<TItemType> : IList<TItemType>, IEquatable<IList<TItemType>>, IEquatable<CollectionItemPicker<TItemType>>
14+
public class CollectionItemPicker<TItemType> : IList<TItemType>, IEquatable<IList<TItemType>>, IEquatable<CollectionItemPicker<TItemType>>, ISerializationCallbackReceiver
1515
where TItemType : ScriptableObject, ISOCItem
1616
{
1717
[SerializeField, FormerlySerializedAs("cachedIndirectReferences")]
@@ -343,5 +343,14 @@ public bool Equals(CollectionItemPicker<TItemType> other)
343343

344344
return true;
345345
}
346+
347+
public void OnBeforeSerialize()
348+
{
349+
}
350+
351+
public void OnAfterDeserialize()
352+
{
353+
isDirty = true;
354+
}
346355
}
347356
}

0 commit comments

Comments
 (0)