Version: 2019.1

Vector2

struct in UnityEngine

Switch to Manual

Description

Представление 2D vector'ов и точек.

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.

Static Variables

downShorthand for writing Vector2(0, -1).
leftShorthand for writing Vector2(-1, 0).
negativeInfinityShorthand for writing Vector2(float.NegativeInfinity, float.NegativeInfinity).
oneСокращенное написание Vector2(1,1)
positiveInfinityShorthand for writing Vector2(float.PositiveInfinity, float.PositiveInfinity).
rightСокращенное написание Vector2(1,0)
upСокращение написания Vector2(0,1)
zeroСокращенное написание Vector2(0,0)

Variables

magnitudeВозвращает длину этого vector'a
normalizedReturns this vector with a magnitude of 1 (Read Only).
sqrMagnitudeВозвращает квадрат длины этого vector'a (Read Only)
this[int]Доступ к x или y компонентам используются [0] или [1] соответственно
xX компонент vector'a
yY компонент вектора.

Constructors

Vector2Создает новый вектор с заданными х, у данными

Public Functions

EqualsReturns true if the given vector is exactly equal to this vector.
NormalizeMakes this vector have a magnitude of 1.
SetSet x and y components of an existing Vector2.
ToStringВозвращает отформатированной строки для этого vector'a

Static Functions

AngleReturns the unsigned angle in degrees between from and to.
ClampMagnitudeReturns a copy of vector with its magnitude clamped to maxLength.
DistanceВозвращает длину между а и /b/
DotDot Product of two vectors.
LerpLinearly interpolates between vectors a and b by t.
LerpUnclampedLinearly interpolates between vectors a and b by t.
MaxВозвращает vector, который сделан из компонентов двух vector'oв
MinВозвращает vector, который сделан из мелких компонентов двух vector'oв
MoveTowardsПеремещает из точки curren в /target /
PerpendicularReturns the 2D vector perpendicular to this 2D vector. The result is always rotated 90-degrees in a counter-clockwise direction for a 2D coordinate system where the positive Y axis goes up.
ReflectReflects a vector off the vector defined by a normal.
ScaleПокомпонентное умножение двух vector'oв
SignedAngleReturns the signed angle in degrees between from and to.
SmoothDampGradually changes a vector towards a desired goal over time.

Operators

operator -Вычитает один vector из другого
operator *Умножает vector на число
operator /Делит vector на число
operator +Добавляет два вектора.
operator ==Returns true if two vectors are approximately equal.
Vector2Converts a Vector3 to a Vector2.
Vector3Converts a Vector2 to a Vector3.