Unity Clamp Circle
Returns min if value is over the max returns max if value bellow min.
A very simple method that i find quite useful to have: Returns min if value is over the max returns max if value is bellow min.
public static int ClampCircle(int p_value, int p_min, int p_max)
{
if (p_value > p_max)
{
return p_min;
}
else if (p_value < p_min)
{
return p_max;
}
else
{
return p_value;
}
}