From 4c8534b7b36e77a7c7c47a10b163695686391739 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sun, 1 Feb 2026 10:13:56 +0800 Subject: 整合素材 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Mountools/Tools/MountoolsMath.cs | 58 +++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 Assets/Mountools/Tools/MountoolsMath.cs (limited to 'Assets/Mountools/Tools/MountoolsMath.cs') diff --git a/Assets/Mountools/Tools/MountoolsMath.cs b/Assets/Mountools/Tools/MountoolsMath.cs new file mode 100755 index 0000000..3b982e5 --- /dev/null +++ b/Assets/Mountools/Tools/MountoolsMath.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Linq.Expressions; +using UnityEngine; + +#if UNITY_EDITOR +using UnityEditorInternal; +#endif + +namespace Mountools.Tools +{ + public static class MountoolsMath + { + public static bool IsInRange(int n, int min, int max, bool equals = true) + { + return equals ? + n <= max && n >= min : + n < max && n > min ; + } + + public static bool IsInRange(float n, float min, float max, bool equals = true) + { + return equals ? + n <= max && n >= min : + n < max && n > min ; + } + + public static int InRange(int n, int min, int max) + { + if (n < min) return min; + if (n > max) return max; + return n; + } + + public static float InRange(float n, float min, float max) + { + if (n < min) return min; + if (n > max) return max; + return n; + } + + public static float To(float a, float b, float t) + { + if (a > b) return InRange(a - t, b, a); + if (a < b) return InRange(a + t, a, b); + return a; + } + + public static int To(int a, int b, int t) + { + if (a > b) return InRange(a - t, b, a); + if (a < b) return InRange(a + t, a, b); + return a; + } + } +} -- cgit