用于表示 2D 向量和点。
down | 用于编写 Vector2(0, -1) 的简便方法。 |
left | 用于编写 Vector2(-1, 0) 的简便方法。 |
negativeInfinity | 用于编写 Vector2(float.NegativeInfinity, float.NegativeInfinity) 的简便方法。 |
one | 用于编写 Vector2(1, 1) 的简便方法。 |
positiveInfinity | 用于编写 Vector2(float.PositiveInfinity, float.PositiveInfinity) 的简便方法。 |
right | 用于编写 Vector2(1, 0) 的简便方法。 |
up | 用于编写 Vector2(0, 1) 的简便方法。 |
zero | 用于编写 Vector2(0, 0) 的简便方法。 |
magnitude | 返回该向量的长度。(只读) |
normalized | 返回 magnitude 为 1 时的该向量。(只读) |
sqrMagnitude | 返回该向量的平方长度。(只读) |
this[int] | 分别使用 [0] 或 [1] 访问 x 或 y 分量。 |
x | 向量的 X 分量。 |
y | 向量的 Y 分量。 |
Vector2 | 使用给定的 x、y 分量构造新向量。 |
Equals | 如果给定向量与该向量完全相等,则返回 true。 |
Normalize | 使该向量的 magnitude 为 1。 |
Set | 设置现有 Vector2 的 x 和 y 分量。 |
ToString | Returns a formatted string for this vector. |
Angle | 返回 from 与 to 之间的无符号角度(以度为单位)。 |
ClampMagnitude | 返回 vector 的副本,其大小被限制为 /maxLength/。 |
Distance | 返回 a 与 b 之间的距离。 |
Dot | 两个向量的点积。 |
Lerp | 在向量 a 与 b 之间按 t 进行线性插值。 |
LerpUnclamped | 在向量 a 与 b 之间按 t 进行线性插值。 |
Max | 返回由两个向量的最大分量组成的向量。 |
Min | 返回由两个向量的最小分量组成的向量。 |
MoveTowards | 将点 current 移向 /target/。 |
Perpendicular | 返回垂直于该 2D 向量的 2D 向量。对于正 Y 轴向上的 2D 坐标系来说,结果始终沿逆时针方向旋转 90 度。 |
Reflect | 从法线定义的向量反射一个向量。 |
Scale | 将两个向量的分量相乘。 |
SignedAngle | 返回 from 与 to 之间的有符号角度(以度为单位)。 |
SmoothDamp | 随时间推移将一个向量逐渐改变为所需目标。 |
operator - | 将一个向量减去另一个向量。 |
operator * | 将向量乘以一个数值。 |
operator / | 将向量除以一个数值。 |
operator + | 将两个向量相加。 |
operator == | 如果两个向量大致相等,则返回 true。 |
Vector2 | 将 Vector3 转换为 Vector2。 |
Vector3 | 将 Vector2 转换为 Vector3。 |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.