Vector2Int Struct
Description
The Vector2Int struct represents a 2D vector with integer components.
Properties
x
: The X component of the vector.y
: The Y component of the vector.
Methods
Equals(other: Vector2Int): boolean
: Compares this vector with another vector and returns true if they are equal.GetHashCode(): number
: Returns the hash code for this vector.
Operators
operator +(v1: Vector2Int, v2: Vector2Int): Vector2Int
: Adds two vectors component-wise and returns the result as a new vector.operator ==(v1: Vector2Int, v2: Vector2Int): boolean
: Returns true if the two vectors are equal.operator !=(v1: Vector2Int, v2: Vector2Int): boolean
: Returns true if the two vectors are not equal.
Usage
To use the Vector2Int struct, you can create instances of it and access its properties and methods. Here's an example:
// Creating a Vector2Int instance
Vector2 v1 = new Vector2Int(3, 5);
Vector2 v2 = new Vector2Int(2, 8);
// Accessing vector components
int x = v1.x; // 3
int y = v1.y; // 5
// Adding two vectors
Vector2 sum = v1 + v2; // (5, 13)
// Comparing two vectors
bool equal = v1 == v2; // false
bool notEqual = v1 != v2; // true