/// <summary> /// 获取有交叉的所有碰撞体和触发器,会包括自身 /// </summary> /// <param name="self"></param> /// <param name="detectLayer"></param> /// <param name="currentPosition"></param> /// <returns></returns> private static Collider[] GetOverlap(this SphereCollider self, int detectLayer, Vector3?currentPosition = null) { return(Physics.OverlapSphere( currentPosition ?? self.GetCenterPosition(), self.radius, detectLayer)); }
/// <summary> /// 获取有交叉的所有碰撞体和触发器,会包括自身,但不会申请内存 /// </summary> /// <param name="self"></param> /// <param name="detectLayer"></param> /// <param name="results"></param> /// <param name="currentPosition"></param> /// <returns></returns> private static int GetOverlapNoAlloc(this SphereCollider self, int detectLayer, Collider[] results, Vector3?currentPosition = null) { return(Physics.OverlapSphereNonAlloc( currentPosition ?? self.GetCenterPosition(), self.radius, results, detectLayer)); }
private static void DrawSelfGizmos(this SphereCollider self) { Gizmos.DrawWireSphere( self.GetCenterPosition(), self.radius); }