1118OPSSNew/Assets/NewScripts/Camera Orbit/MathfUtils.cs

27 lines
563 B
C#

using UnityEngine;
/// <summary>
/// 数学工具
/// </summary>
public class MathfUtils
{
/// <summary>
/// 限制角度
/// </summary>
/// <param name="angle"></param>
/// <param name="min"></param>
/// <param name="max"></param>
/// <returns></returns>
public static float ClampAngle(float angle, float min, float max)
{
if (angle < -360f)
{
angle += 360f;
}
if (angle > 360f)
{
angle -= 360f;
}
return Mathf.Clamp(angle, min, max);
}
}