public int GetContacts (ContactPoint2D[] contacts);

Parameters

contacts用于获取这些结果的 ContactPoint2D 数组。

Returns

int 返回放置在 contacts 数组中的接触数。

Description

Retrieves all contact points for all of the Collider(s) attached to this Rigidbody.

Contacts involving a Collider2D set to be a trigger will never be returned here because trigger Colliders do not have contact points.

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

另请参阅:Collider2D.GetContactsPhysics2D.GetContacts


public int GetContacts (Collider2D[] colliders);

Parameters

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

Returns

int 返回放置在 colliders 数组中的碰撞体数。

Description

Retrieves all Colliders in contact with any of the Collider(s) attached to this Rigidbody.

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

另请参阅:Collider2D.GetContactsPhysics2D.GetContacts


public int GetContacts (ContactFilter2D contactFilter, ContactPoint2D[] contacts);

Parameters

contactFilter接触筛选器,用于以不同方式筛选结果,例如按层遮罩、Z 深度或法线角度。
contacts用于获取这些结果的 ContactPoint2D 数组。

Returns

int 返回放置在 contacts 数组中的接触数。

Description

Retrieves all contact points for all of the Collider(s) attached to this Rigidbody, with the results filtered by the ContactFilter2D.

Contacts involving a Collider2D set to be a trigger will never be returned here because trigger Colliders do not have contact points. This is true even if the contactFilter has its ContactFilter2D.useTriggers set to true.

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

另请参阅:Collider2D.GetContactsPhysics2D.GetContacts


public int GetContacts (ContactFilter2D contactFilter, Collider2D[] colliders);

Parameters

contactFilter接触筛选器,用于以不同方式筛选结果,例如按层遮罩、Z 深度或法线角度。
colliders用于获取这些结果的 Collider2D 数组。

Returns

int 返回放置在 colliders 数组中的碰撞体数。

Description

Retrieves all Colliders in contact with any of the Collider(s) attached to this rigidbody, with the results filtered by the ContactFilter2D.

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

另请参阅:Collider2D.GetContactsPhysics2D.GetContacts


Parameters

contactsA list of ContactPoint2D used to receive the results.

Returns

void Returns the number of contacts placed in the contacts list.

Description

Retrieves all contact points for all of the Collider(s) attached to this Rigidbody.

Contacts involving a Collider2D set to be a trigger will never be returned here because trigger Colliders do not have contact points.

The integer return value is the number of results written into the contacts list. The contacts 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 contacts list does not need to be resized, and improves garbage collection performance when the query is performed frequently.

另请参阅:Collider2D.GetContactsPhysics2D.GetContacts


Parameters

contactFilter接触筛选器,用于以不同方式筛选结果,例如按层遮罩、Z 深度或法线角度。
contactsA list of ContactPoint2D used to receive the results.

Returns

void Returns the number of contacts placed in the contacts list.

Description

Retrieves all contact points for all of the Collider(s) attached to this Rigidbody.

Contacts involving a Collider2D set to be a trigger will never be returned here because trigger Colliders do not have contact points.

The integer return value is the number of results written into the contacts list. The contacts 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 contacts list does not need to be resized, and improves garbage collection performance when the query is performed frequently.

The results can also be filtered by the contactFilter.

另请参阅:Collider2D.GetContactsPhysics2D.GetContacts


Parameters

collidersA list of Collider2D used to receive the results.

Returns

void Returns the number of Colliders placed in the colliders list.

Description

Retrieves all Colliders in contact with any of the Collider(s) attached to this Rigidbody.

The integer return value is the number of results written into the colliders list. The contacts 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 colliders list does not need to be resized, and improves garbage collection performance when the query is performed frequently.

另请参阅:Collider2D.GetContactsPhysics2D.GetContacts


Parameters

contactFilter接触筛选器,用于以不同方式筛选结果,例如按层遮罩、Z 深度或法线角度。
collidersA list of Collider2D used to receive the results.

Returns

void Returns the number of Colliders placed in the colliders list.

Description

Retrieves all Colliders in contact with any of the Collider(s) attached to this Rigidbody.

The integer return value is the number of results written into the colliders list. The contacts 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 colliders list does not need to be resized, and improves garbage collection performance when the query is performed frequently.

The results can also be filtered by the contactFilter.

另请参阅:Collider2D.GetContactsPhysics2D.GetContacts