Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


operator *

Multiplies a vector by another vector.
Read time 1 minuteLast updated 4 days ago

Definition

  • Type: Operator
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule

operator *(Vector2, Vector2)

Multiplies a vector by another vector.
public static Vector2 operator *(Vector2 a, Vector2 b)

Parameters

The first vector to multiply.

The second vector to multiply.

Returns

Type

Description

Vector2

Remarks

Multiplies each component of
a
by its matching component from
b
.

operator *(Vector2, float)

Multiplies a vector by a number.
public static Vector2 operator *(Vector2 a, float d)

Parameters

The vector to multiply by.

The number to multiply by.

Returns

Type

Description

Vector2

Remarks

Multiplies each component of
a
by a number
d
.

Examples

using UnityEngine;public class Example : MonoBehaviour{ void Start() { // make the vector twice longer: prints (2.0,4.0) print(new Vector2(1, 2) * 2.0f); }}

operator *(float, Vector2)

Multiplies a vector by a number.
public static Vector2 operator *(float d, Vector2 a)

Parameters

The number to multiply by.

The vector to multiply by.

Returns

Type

Description

Vector2

Remarks

Multiplies each component of
a
by a number
d
.

Examples

using UnityEngine;public class Example : MonoBehaviour{ void Start() { // make the vector twice longer: prints (2.0,4.0) print(2.0f * new Vector2(1, 2)); }}