int Item { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The Item property of the Vector2Int struct allows you to access the components of the vector using an indexer. This property provides a way to get or set the X or Y component of the vector using an integer index.

Usage

Use the Item property to access the X or Y component of a Vector2Int instance by index. The index 0 corresponds to the X component, and the index 1 corresponds to the Y component.

For example, vector[0] will return or set the X component, while vector[1] will return or set the Y component.

Example

Vector2Int vector = new Vector2Int(3, 5);

// Accessing components using the Item property
int xComponent = vector[0]; // xComponent is 3
int yComponent = vector[1]; // yComponent is 5

// Setting components using the Item property
vector[0] = 10; // Sets the X component to 10
vector[1] = 20; // Sets the Y component to 20