Vector2Int
Representation of 2D vectors and points using integers.
阅读时间2 分钟最后更新于 6 小时前
Definition
- Type: Struct
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
- Implements: IEquatable<Vector2Int>, IFormattable
public struct Vector2Int : IEquatable<Vector2Int>, IFormattable
Remarks
This structure is used in some places to represent 2D positions and vectors that don't require the precision of floating-point.
Properties
Property | Description |
|---|---|
| this[] | Access the |
| magnitude | Returns the length of this vector (Read Only). |
| sqrMagnitude | Returns the squared length of this vector (Read Only). |
| x | X component of the vector. |
| y | Y component of the vector. |
Static Properties
Property | Description |
|---|---|
| down | Shorthand for writing |
| left | Shorthand for writing |
| one | Shorthand for writing |
| right | Shorthand for writing |
| up | Shorthand for writing |
| zero | Shorthand for writing |
Methods
Method | Description |
|---|---|
| Clamp | Clamps the |
| Equals | Evaluates if a vector and obejct are equal to each other. |
| GetHashCode | Gets the hash code for the |
| Scale | Multiplies every component of this vector by the same component of |
| Set | Set x and y components of an existing Vector2Int. |
| ToString | Formats this vector as a string. |
Static Methods
Method | Description |
|---|---|
| CeilToInt | Converts a Vector2 to a Vector2Int by doing a Ceiling to each value. |
| Distance | Calculates the distance between two vectors. |
| FloorToInt | Converts a Vector2 to a Vector2Int by doing a Floor to each value. |
| Max | Creates a vector that is made from the largest components of two vectors. |
| Min | Creates a vector that is made from the smallest components of two vectors. |
| RoundToInt | Converts a Vector2 to a Vector2Int by doing a Round to each value. |
| Scale | Multiplies two vectors component-wise. |
Operators
Operator | Description |
|---|---|
| operator + | Adds two vectors. |
| operator / | Divides a vector by a number. |
| operator == | Returns true if the vectors are equal. |
| Vector3Int | Converts a Vector2Int to a Vector3Int. |
| Vector2 | Converts a Vector2Int to a Vector2. |
| operator != | Returns true if the vectors are different. |
| operator * | Multiplies a vector by a number. |
| operator - | Subtracts one vector from another. |