unity 中文API之Vector2

Vector2 二維向量

unity 中文API之Vector2

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。


分享到:


相關文章: