Skip to content

Ray Extensions

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

UtilityLibrary.Unity.Runtime

Deconstruct

Ray.Deconstruct

Deconstructs a Ray instance into its origin and direction vectors.

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

Parameters:

  • ray: The Ray instance.

Outputs:

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

With

Ray.With

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

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

Parameters:

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

Returns:

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

Clone this wiki locally