book_4_sparkGenerated
code_blocksInput

Description

The Vector2Int.One field is a static, read-only field of the Vector2Int struct. It represents a 2D integer vector where both the X and Y components are set to 1. This field is useful for operations where a unit vector with integer components is required, such as scaling or directional operations in grid-based systems.

Usage

You can use Vector2Int.One whenever you need a vector with both components set to 1. This is particularly useful in scenarios where you need to initialize or compare vectors with a standard unit vector in integer space.

Example

// Example usage of Vector2Int.One
Vector2Int unitVector = Vector2Int.One;

// This will output: (1, 1)
Debug.Log($"Unit Vector: ({unitVector.x}, {unitVector.y})");

// Using Vector2Int.One in a calculation
Vector2Int position = new Vector2Int(5, 10);
Vector2Int newPosition = position + Vector2Int.One;

// This will output: (6, 11)
Debug.Log($"New Position: ({newPosition.x}, {newPosition.y})");