public int GetContacts (ContactPoint2D[] contacts);

Parameters

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

Returns

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

Description

Retrieves all contact points for this Collider.

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

您应传入一个大到足以包含您想要返回的所有接触的数组。这个数组一般会被重用,因此其大小应能够返回合理数量的接触。此函数不进行分配,这意味着不需要垃圾回收器进行回收。

另请参阅:Rigidbody2D.GetContactsPhysics2D.GetContacts


public int GetContacts (Collider2D[] colliders);

Parameters

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

Returns

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

Description

Retrieves all colliders in contact with this Collider.

您应传入一个大到足以包含您想要返回的所有接触的数组。这个数组一般会被重用,因此其大小应能够返回合理数量的接触。此函数不进行分配,这意味着不需要垃圾回收器进行回收。

另请参阅:Rigidbody2D.GetContactsPhysics2D.GetContacts


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

Parameters

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

Returns

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

Description

Retrieves all contact points for this Collider, with the results filtered by the contactFilter.

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.

您应传入一个大到足以包含您想要返回的所有接触的数组。这个数组一般会被重用,因此其大小应能够返回合理数量的接触。此函数不进行分配,这意味着不需要垃圾回收器进行回收。

另请参阅:Rigidbody2D.GetContactsPhysics2D.GetContacts


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

Parameters

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

Returns

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

Description

Retrieves all colliders in contact with this Collider, with the results filtered by the contactFilter.

您应传入一个大到足以包含您想要返回的所有接触的数组。这个数组一般会被重用,因此其大小应能够返回合理数量的接触。此函数不进行分配,这意味着不需要垃圾回收器进行回收。

另请参阅:Rigidbody2D.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 this Collider.

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

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.GetContactsPhysics2D.GetContacts


Parameters

collidersA list of Collider2D used to receive the results.

Returns

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

Description

Retrieves all colliders in contact with this Collider.

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.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 this Collider, with the results filtered by the contactFilter.

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

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.GetContactsPhysics2D.GetContacts


Parameters

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

Returns

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

Description

Retrieves all colliders in contact with this Collider, with the results filtered by the contactFilter.

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.GetContactsPhysics2D.GetContacts