Skip to content

BoundsInt Extensions

Andrzej Kebab edited this page Feb 2, 2024 · 1 revision

Unity Runtime Utility Library

BoundsIntExtensions

Deconstruct

Deconstructs a BoundsInt instance into its minimum point and size components.

BoundsInt bounds = // Your BoundsInt instance;
int xMin, yMin, zMin, sizeX, sizeY, sizeZ;
bounds.Deconstruct(out xMin, out yMin, out zMin, out sizeX, out sizeY, out sizeZ);

Parameters:

  • bounds: The BoundsInt instance.
  • xMin: The minimum x-coordinate of the BoundsInt.
  • yMin: The minimum y-coordinate of the BoundsInt.
  • zMin: The minimum z-coordinate of the BoundsInt.
  • sizeX: The size of the BoundsInt along the x-axis.
  • sizeY: The size of the BoundsInt along the y-axis.
  • sizeZ: The size of the BoundsInt along the z-axis.

Deconstructs a BoundsInt instance into its position and size components.

BoundsInt bounds = // Your BoundsInt instance;
Vector3Int position, size;
bounds.Deconstruct(out position, out size);

Parameters:

  • bounds: The BoundsInt instance.
  • position: The position of the BoundsInt.
  • size: The size of the BoundsInt.

Deconstructs a BoundsInt instance into its position, size, min, and max components.

BoundsInt bounds = // Your BoundsInt instance;
Vector3Int position, size, min, max;
bounds.Deconstruct(out position, out size, out min, out max);

Parameters:

  • bounds: The BoundsInt instance.
  • position: The position of the BoundsInt.
  • size: The size of the BoundsInt.
  • min: The minimum point of the BoundsInt.
  • max: The maximum point of the BoundsInt.

With

Creates a new BoundsInt instance with the specified position and size, or the original position and size if not specified.

BoundsInt bounds = // Your original BoundsInt instance;
Vector3Int? position = // Your new position, or null to keep the original position;
Vector3Int? size = // Your new size, or null to keep the original size;
BoundsInt result = bounds.With(position, size);

Parameters:

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

Returns:

  • result: A new BoundsInt instance with the specified position and size.

Clone this wiki locally