Skip to content

Bounds Extensions

Andrzej Kebab edited this page Feb 2, 2024 · 2 revisions

Unity Runtime Utility Library

Deconstruct

Deconstructs a Bounds instance into its center and size components.

Bounds bounds = // Your Bounds instance;
Vector3 center, size;
bounds.Deconstruct(out center, out size);

Parameters:

  • bounds: The Bounds instance.
  • center: The center of the Bounds.
  • size: The size of the Bounds.

Deconstructs a Bounds instance into its center, size, min, and max components.

Bounds bounds = // Your Bounds instance;
Vector3 center, size, min, max;
bounds.Deconstruct(out center, out size, out min, out max);

Parameters:

  • bounds: The Bounds instance.
  • center: The center of the Bounds.
  • size: The size of the Bounds.
  • min: The minimum point of the Bounds.
  • max: The maximum point of the Bounds.

With

Creates a new Bounds instance with the specified center and size, or the original center and size if not specified.

Bounds bounds = // Your original Bounds instance;
Vector3? center = // Your new center, or null to keep the original center;
Vector3? size = // Your new size, or null to keep the original size;
Bounds result = bounds.With(center, size);

Parameters:

  • bounds: The original Bounds instance.
  • center: The center of the new Bounds. If null, the center of the original Bounds is used.
  • size: The size of the new Bounds. If null, the size of the original Bounds is used.

Returns:

  • result: A new Bounds instance with the specified center and size.

Clone this wiki locally