Firstborn/Library/PackageCache/com.unity.inputsystem@1.5.1/InputSystem/Utilities/MiscHelpers.cs
Schaken-Mods 9092858a58 updated to the latest editor
I updated everything to the latest Unity Editor. Also realized I had the wrong shaders on my hairs, those are fixed and the hairs look MUCH better!
2023-05-07 17:43:11 -05:00

41 lines
1.2 KiB
C#

using System.Collections.Generic;
namespace UnityEngine.InputSystem.Utilities
{
internal static class MiscHelpers
{
public static TValue GetValueOrDefault<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key)
{
return dictionary.TryGetValue(key, out var value) ? value : default;
}
public static IEnumerable<TValue> EveryNth<TValue>(this IEnumerable<TValue> enumerable, int n, int start = 0)
{
var index = 0;
foreach (var element in enumerable)
{
if (index < start)
{
++index;
continue;
}
if ((index - start) % n == 0)
yield return element;
++index;
}
}
public static int IndexOf<TValue>(this IEnumerable<TValue> enumerable, TValue value)
{
var index = 0;
foreach (var element in enumerable)
if (EqualityComparer<TValue>.Default.Equals(element, value))
return index;
else
++index;
return -1;
}
}
}