using System;
using UnityEngine;
/// <summary>
/// 物理辅助类
/// </summary>
public sealed class PhysicsHelper
{
// Physics.RaycastAll()返回的结果是无序的
// 将射线返回的碰撞对象按距离排序
public static void SortRaycastHit(ref RaycastHit[] hits)
{
Array.Sort<RaycastHit>(hits,
(a, b) => {
if (a.distance < b.distance)
return -1;
else if (a.distance > b.distance)
return 1;
return 0;
});
}
}