From cae12a43fc1cf5a66c33202aeeb48b537d5787d9 Mon Sep 17 00:00:00 2001 From: vis2k Date: Sun, 12 Mar 2023 22:50:13 +0800 Subject: [PATCH] Mathd.Clamp for Unity 2020 support --- Assets/Mirror/Core/Tools/Mathd.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Assets/Mirror/Core/Tools/Mathd.cs b/Assets/Mirror/Core/Tools/Mathd.cs index af5d7b8a4..ddef15a36 100644 --- a/Assets/Mirror/Core/Tools/Mathd.cs +++ b/Assets/Mirror/Core/Tools/Mathd.cs @@ -5,6 +5,16 @@ namespace Mirror { public static class Mathd { + // Unity 2020 doesn't have Math.Clamp yet. + /// Clamps value between 0 and 1 and returns value. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static double Clamp(double value, double min, double max) + { + if (value < min) return min; + if (value > max) return max; + return value; + } + /// Clamps value between 0 and 1 and returns value. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static double Clamp01(double value)