Rigidbody2D.GetAttachedColliders

Switch to Manual
public int GetAttachedColliders (out Collider2D[] results);

Parameters

results用于获取这些结果的 Collider2D 数组。

Returns

int 返回放置在 results 数组中的 Collider2D 数。

Description

返回附加到该 Rigidbody2D 的所有 Collider2D

计算附加到该 Rigidbody2D 的所有 Collider2D,并在 results 数组中返回它们。

当获取碰撞体时,应确保提供的数组足够大,能够包含您感兴趣的所有碰撞体。该数组一般会重用,因此其大小应能够返回合理数量的碰撞体。此函数还意味着不发生分配,因此不需要垃圾回收器进行回收。

另请参阅:Rigidbody2D.attachedColliderCount


Parameters

resultsA list of Collider2D used to receive the results.

Returns

void Returns the number of Collider2D placed in the results list.

Description

返回附加到该 Rigidbody2D 的所有 Collider2D

Calculates all Collider2D that are attached to this Rigidbody2D and returns them in the results list.

The integer return value is the number of results written into the results list. The results list will be resized if it doesn't contain enough elements to report all the results. This prevents memory from being allocated for results when the results list does not need to be resized, and improves garbage collection performance when the query is performed frequently.

另请参阅:Rigidbody2D.attachedColliderCount