/// <summary> /// 向某个方向做检测,对获取到的trigger和collider做操作 /// </summary> /// <param name="self"></param> /// <param name="dir"></param> /// <param name="distance"></param> /// <param name="layer"></param> /// <param name="cache"></param> /// <param name="onHitOther"></param> /// <param name="ignoreSet"></param> public static void CastActionNoAlloc(this Collider self, Vector3 dir, float distance, int layer, RaycastHit[] cache, Action <RaycastHit> onHitOther, HashSet <Collider> ignoreSet = null, Vector3?centerOffset = null) { var count = self.CastNoAlloc(dir, distance, layer, cache, centerOffset); for (var i = 0; i < count; i++) { var hitInfo = cache[i]; if (ignoreSet != null && ignoreSet.Contains(hitInfo.collider)) { continue; } onHitOther.Invoke(hitInfo); } }