Skip to content

Commit c566ee8

Browse files
committed
add: allow null items
1 parent 2773bf9 commit c566ee8

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

Scripts/Runtime/Core/CollectionItemQuery.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,18 @@ public override string ToString()
7272
/// Returns <c>true</c> only if every set passes its <see cref="MatchType"/> check;
7373
/// an empty query returns <c>true</c>.
7474
/// </summary>
75-
/// <param name="targetItems">The items to test against (e.g., the tags on a rigidbody).</param>
75+
/// <param name="targetItems">The items to test against (e.g., the tags on a rigidbody). A null collection is treated as empty, so positive sets (<see cref="MatchType.Any"/>/<see cref="MatchType.All"/>) fail and negative sets (<see cref="MatchType.NotAny"/>/<see cref="MatchType.NotAll"/>) pass.</param>
7676
/// <param name="resultMatchCount">Total number of individual picker items found across all query sets. Informational only; does not affect the return value.</param>
7777
public bool Matches(IEnumerable<T> targetItems, out int resultMatchCount)
7878
{
7979
targetGuids.Clear();
80-
foreach (T item in targetItems)
80+
if (targetItems != null)
8181
{
82-
if (item)
83-
targetGuids.Add(item.GUID);
82+
foreach (T item in targetItems)
83+
{
84+
if (item)
85+
targetGuids.Add(item.GUID);
86+
}
8487
}
8588

8689
resultMatchCount = 0;

0 commit comments

Comments
 (0)