mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
fix: Add Clamp extension for pre-Unity 2021
This commit is contained in:
parent
53658a5886
commit
98b8227a63
@ -130,7 +130,11 @@ public static double TimelineClamp(
|
||||
// outside of the area, we clamp.
|
||||
double lowerBound = targetTime - bufferTime;
|
||||
double upperBound = targetTime + bufferTime;
|
||||
#if !UNITY_2021_OR_NEWER
|
||||
return Extensions.Clamp(localTimeline, lowerBound, upperBound);
|
||||
#else
|
||||
return Math.Clamp(localTimeline, lowerBound, upperBound);
|
||||
#endif
|
||||
}
|
||||
|
||||
// call this for every received snapshot.
|
||||
|
@ -59,6 +59,14 @@ public static bool TryDequeue<T>(this Queue<T> source, out T element)
|
||||
element = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T Clamp<T>(this T val, T min, T max) where T : IComparable<T>
|
||||
{
|
||||
if (val.CompareTo(min) < 0) return min;
|
||||
else if (val.CompareTo(max) > 0) return max;
|
||||
else return val;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user