Description
The Sort
method is a static method of the Vector3
struct. It is used to sort two Vector3
instances by their components, ensuring that the min
vector has the smallest components and the max
vector has the largest components. This method modifies the input vectors directly.
Usage
To use the Sort
method, you need to pass two Vector3
references as parameters. The method will compare the components of the two vectors and adjust them so that the first vector contains the minimum values and the second vector contains the maximum values for each component.
Example
Vector3 min = new Vector3(3, 5, 7);
Vector3 max = new Vector3(1, 6, 2);
// Before sorting
// min: (3, 5, 7)
// max: (1, 6, 2)
Vector3.Sort(ref min, ref max);
// After sorting
// min: (1, 5, 2)
// max: (3, 6, 7)