Vector2.operator -

Unity · Версия 2020.3 LTS · Scripting · Vector2

Vector2.operator -

public static Vector2 operator -(Vector2 a, Vector2 b);

Описание

Вычитает один вектор из другого.

Вычитает каждый компонент b из a.

using UnityEngine;

public class Example : MonoBehaviour
{
    void Start()
    {
        // prints (-2.0,0.0)
        print(new Vector2(1, 2) - new Vector2(3, 2));
    }
}

public static Vector2 operator -(Vector2 a);

Описание

Отменяет вектор.

Каждый компонент результата инвертируется.

using UnityEngine;

public class Example : MonoBehaviour
{
    void Start()
    {
        // prints (-1.0,-2.0)
        print(-new Vector2(1, 2));
    }
}

Обновлено 17 ноября 2026 г.