mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
fix: added Queue.TryDequeue extension for Unity 2019
This commit is contained in:
parent
6c2559a73e
commit
3d471db938
@ -38,5 +38,20 @@ public static void CopyTo<T>(this IEnumerable<T> source, List<T> destination)
|
|||||||
// foreach allocates. use AddRange.
|
// foreach allocates. use AddRange.
|
||||||
destination.AddRange(source);
|
destination.AddRange(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !UNITY_2020_1_OR_NEWER
|
||||||
|
// Unity 2019 doesn't have Queue.TryDeque which we need for batching.
|
||||||
|
public static bool TryDequeue<T>(this Queue<T> source, out T element)
|
||||||
|
{
|
||||||
|
if (source.Count > 0)
|
||||||
|
{
|
||||||
|
element = source.Dequeue();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
element = default;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user