Skip to content

ColliderExtensions

Namespace: SideXP.Core

public static class ColliderExtensions

Extension functions for Collider components. See Collider2DExtensions for 2D colliders.

Methods

GetColliderBounds(Collider)

public static Bounds GetColliderBounds(Collider collider)

Gets the bounds of a collider.

Parameters

  • collider: The collider of which to query the bounds.

Returns

Returns the collider bounds.

Remarks

While the game is running, the physics system provides accurate world bounds through bounds. At edit time (or for a prefab) that representation isn't baked, and reading it (even through the concrete collider type) returns a zeroed value. In that case the bounds are computed from the collider's geometry (center/size/radius/mesh) transformed into world space instead. Note: for a rotated non-box collider the computed AABB is slightly looser than the physics one.

GetColliderBounds(Collider, Bounds)

public static bool GetColliderBounds(Collider collider, out Bounds bounds)

Gets the bounds of a collider.

Parameters

  • collider: The collider of which to query the bounds.
  • bounds: Outputs the collider bounds.

Returns

Returns true if the collider type is supported (box, sphere, capsule, or mesh with a shared mesh).

Remarks

While the game is running, the physics system provides accurate world bounds through bounds. At edit time (or for a prefab) that representation isn't baked, and reading it (even through the concrete collider type) returns a zeroed value. In that case the bounds are computed from the collider's geometry (center/size/radius/mesh) transformed into world space instead. Note: for a rotated non-box collider the computed AABB is slightly looser than the physics one.