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