int Item { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The Item property of the Vector3Int struct allows you to access or modify the individual components of the vector using an indexer. This property provides a way to treat the vector as an array of integers, where the index 0 corresponds to the X component, index 1 to the Y component, and index 2 to the Z component.

Usage

Use the Item property to access or set the X, Y, or Z components of a Vector3Int instance by index. This is particularly useful when you need to iterate over the components or when you want to dynamically access a component based on a variable index.

Example

Vector3Int vector = new Vector3Int(1, 2, 3);

// Accessing components using the Item property
int x = vector[0]; // x = 1
int y = vector[1]; // y = 2
int z = vector[2]; // z = 3

// Modifying components using the Item property
vector[0] = 10; // Now vector.x = 10
vector[1] = 20; // Now vector.y = 20
vector[2] = 30; // Now vector.z = 30