Files
Cielonos/Packages/dev.yarnspinner.unity/Editor/Analysis/EnumerableExtensions.cs
SoulliesOfficial 8186f54e90 新场景,剧情
2026-06-02 12:55:39 -04:00

30 lines
684 B
C#

/*
Yarn Spinner is licensed to you under the terms found in the file LICENSE.md.
*/
using System;
using System.Collections.Generic;
#nullable enable
static class EnumerableExtensions
{
public static IEnumerable<T> NonNull<T>(this IEnumerable<T?> collection, bool throwIfAnyNull = false) where T : class
{
foreach (var item in collection)
{
if (item != null)
{
yield return item;
}
else
{
if (throwIfAnyNull)
{
throw new NullReferenceException("Collection contains a null item");
}
}
}
}
}