Skip to content

Ray2D Extensions

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

UtilityLibrary.Unity.Runtime

Deconstruct

Ray2D.Deconstruct

Deconstructs a Ray2D instance into its origin and direction vectors.

Ray2D ray = // initialize your Ray2D
Vector3 origin, direction;
ray.Deconstruct(out origin, out direction);

Parameters:

  • ray: The Ray2D instance.

Outputs:

  • origin: The origin vector of the Ray2D.
  • direction: The direction vector of the Ray2D.

With

Ray2D.With

Creates a new Ray2D instance with the specified origin and direction vectors, or the original vectors if not specified.

Ray2D originalRay = // initialize your Ray2D
Vector3? origin = // optional
Vector3? direction = // optional
Ray2D newRay = originalRay.With(origin, direction);

Parameters:

  • originalRay: The original Ray2D instance.
  • origin: The origin vector of the new Ray2D. If null, the origin vector of the original Ray2D is used.
  • direction: The direction vector of the new Ray2D. If null, the direction vector of the original Ray2D is used.

Returns:

  • newRay: A new Ray2D instance with the specified origin and direction vectors.

Clone this wiki locally