Vector2 二维向量

unity性能分析手册(unity中文API之Vector2)(1)

Description 描述

Representation of 2D vectors and points.

表示 2D 的向量和点。

This structure is used in some places to represent 2D positions and vectors (e.g. texture coordinates in a Mesh or texture offsets in Material). In the majority of other cases a Vector3 is used.

这个结构用于在一些地方表示2D的位置和向量(例如:网格中的纹理坐标,或者材质中的纹理偏移)。在其他情况下大多数使用Vector3。

Static Variables 静态变量

one Shorthand for writing Vector2(1, 1).

Vector2(1, 1)的简写。 right Shorthand for writing Vector2(1, 0).

Vector2(1, 0)的简写。 up Shorthand for writing Vector2(0, 1).

Vector2(0, 1)的简写。 zero Shorthand for writing Vector2(0, 0).

Vector2(0, 0)的简写。

Variables 变量

magnitude Returns the length of this vector (Read Only).

返回向量的长度(只读)。 normalized Returns this vector with a magnitude of 1 (Read Only).

返回向量的长度为1(只读)。 sqrMagnitude Returns the squared length of this vector (Read Only).

返回这个向量的长度的平方(只读)。 this[int] Access the x or y component using [0] or [1] respectively.

使用(索引器)[0]或者[1]分别访问组件x或者y组件。 x X component of the vector.

向量的X组件。 y Y component of the vector.

向量的Y组件。

Constructors 构造器

Vector2 Constructs a new vector with given x, y components.

创建一个新的具有给定x,y组件的向量。

Functions 函数

Normalize Makes this vector have a magnitude of 1.

使向量的长度为1。 Set Set x and y components of an existing Vector2.

设置已知二维变量的x和y。 ToString Returns a nicely formatted string for this vector.

返回该向量一个格式化好的字符串。

Static Functions 静态函数

Angle Returns the angle in degrees between from and to.

在from和to之间返回一个角度。 ClampMagnitude Returns a copy of vector with its magnitude clamped to maxLength.

返回向量的长度,最大不超过maxLength所指示的长度。 Distance Returns the distance between a and b.

返回a和b之间的距离。 Dot Dot Product of two vectors.

两个向量的点乘积。 Lerp Linearly interpolates between two vectors.

两个向量之间的线性插值。 Max Returns a vector that is made from the largest components of two vectors.

返回一个由两个向量的最大组件组成的向量。 Min Returns a vector that is made from the smallest components of two vectors.

返回一个由两个向量的最小组件组成的向量。 MoveTowards Moves a point current towards target.

当前的地点移向目标。 Reflect Reflects a vector off the vector defined by a normal.

定义在正常情况下映射向量离开向量。 Scale Multiplies two vectors component-wise.

两个矢量组件对应相乘。 SmoothDamp Gradually changes a vector towards a desired goal over time.

随着时间的推移逐渐改变一个向量朝着期望的目标。

operators 运算符

operator - Subtracts one vector from another.

一个向量减去另一个向量。 operator != Returns true if vectors different.

如果向量不同返回真。 operator * Multiplies a vector by a number.

一个向量乘以一个数字。 operator / Divides a vector by a number.

一个向量除以一个数字。 operator Adds two vectors.

两个向量相加。 operator == Returns true if the vectors are equal.

如果向量相等返回真。 operator Vector2 Converts a Vector3 to a Vector2.

将一个Vector3转化成一个Vector2。 operator Vector3 Converts a Vector2 to a Vector3.

将一个Vector2转化成一个Vector3。

,