Description
The WithY
method of the Vector3Int
struct allows you to create a new Vector3Int
instance with a specified Y component, while keeping the X and Z components unchanged. This method is useful when you need to modify only the Y component of a vector without affecting the other components.
Usage
To use the WithY
method, call it on an existing Vector3Int
instance and pass the new Y value as an integer parameter. The method returns a new Vector3Int
instance with the updated Y component.
Example
Vector3Int originalVector = new Vector3Int(1, 2, 3);
Vector3Int newVector = originalVector.WithY(5);
// newVector is now (1, 5, 3)