# implicit operator Vector2

> Converts a float2 to a Vector2.

## Definition

* **Type:** Operator
* **Namespace:** [UnityEngine](/engine/6000.6/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## implicit operator Vector2(Vector)

Converts a [float2](/engine/6000.6/script-reference/unity/mathematics/float2.md) to a [Vector2](/engine/6000.6/script-reference/unityengine/vector2.md).

```csharp
public static implicit operator Vector2(float2 v)
```

### Parameters

**** (\[float2]\(/engine/6000.6/script-reference/unity/mathematics/float2)): The float2 to be converted to a Vector2.

### Returns

| Type                                                              | Description                   |
| ----------------------------------------------------------------- | ----------------------------- |
| [Vector2](/engine/6000.6/script-reference/unityengine/vector2.md) | The converted Vector2 result. |

### Remarks

An implicit conversion operator that converts an input [float2](/engine/6000.6/script-reference/unity/mathematics/float2.md) value to a [Vector2](/engine/6000.6/script-reference/unityengine/vector2.md).

### Examples

```csharp
// Attach this script to a GameObject.
using UnityEngine;
using Unity.Mathematics; // brings in float2

public class Example_Vector2_FromFloat2 : MonoBehaviour
{
    void Start()
    {
        float2 a = new float2(4f, 5f);
        Debug.Log("Input float2 is: " + a.ToString());

        // Implicit conversion from Unity.Mathematics.float2 to UnityEngine.Vector2
        Vector2 result = a;
        Debug.Log("Result Vector2 is: " + result.ToString());
    }
}
```

## implicit operator float2(float)

Converts a [Vector2](/engine/6000.6/script-reference/unityengine/vector2.md) to a [float2](/engine/6000.6/script-reference/unity/mathematics/float2.md).

```csharp
public static implicit operator float2(Vector2 v)
```

### Parameters

**** (\[Vector2]\(/engine/6000.6/script-reference/unityengine/vector2)): The Vector2 to be converted to a float2.

### Returns

| Type                                                                  | Description                  |
| --------------------------------------------------------------------- | ---------------------------- |
| [float2](/engine/6000.6/script-reference/unity/mathematics/float2.md) | The converted float2 result. |

### Remarks

An implicit conversion operator that converts an input [Vector2](/engine/6000.6/script-reference/unityengine/vector2.md) value to a [float2](/engine/6000.6/script-reference/unity/mathematics/float2.md).

## implicit operator Vector2(Vector)

Converts a [Vector3](/engine/6000.6/script-reference/unityengine/vector3.md) to a [Vector2](/engine/6000.6/script-reference/unityengine/vector2.md).

```csharp
public static implicit operator Vector2(Vector3 v)
```

### Parameters

**** (\[Vector3]\(/engine/6000.6/script-reference/unityengine/vector3)): The input [Vector3](/engine/6000.6/script-reference/unityengine/vector3.md) value to convert to a [Vector2](/engine/6000.6/script-reference/unityengine/vector2.md).

### Returns

| Type                                                              | Description                                                                                                      |
| ----------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| [Vector2](/engine/6000.6/script-reference/unityengine/vector2.md) | A [Vector2](/engine/6000.6/script-reference/unityengine/vector2.md) initialized with components `v.x` and `v.y`. |

### Remarks

An implicit conversion operator that converts an input [Vector3](/engine/6000.6/script-reference/unityengine/vector3.md) value to a [Vector2](/engine/6000.6/script-reference/unityengine/vector2.md). The [Vector3.x](/engine/6000.6/script-reference/unityengine/vector3/x.md) and [Vector3.y](/engine/6000.6/script-reference/unityengine/vector3/y.md) components are used to initialize the result and the [Vector3.z](/engine/6000.6/script-reference/unityengine/vector3/z.md) component is discarded.

### Examples

```csharp
using UnityEngine;

public class ExampleScript : MonoBehaviour
{
    void Start()
    {
        Vector2 v2 = new Vector2(1, 2);
        Debug.Log("Vector2 is: " + v2);

        // convert v2 to v3
        Vector3 v3 = v2;
        Debug.Log("Vector3 is: " + v3);

        // convert v3 to new Vector3
        Debug.Log("Set v3 to (3, 4, 5)");
        v3 = new Vector3(3, 4, 5);

        // convert v3 to v2
        v2 = v3;
        Debug.Log("Vector2 is: " + v2);
    }
}
```

## implicit operator Vector3(Vector)

Converts a [Vector2](/engine/6000.6/script-reference/unityengine/vector2.md) to a [Vector3](/engine/6000.6/script-reference/unityengine/vector3.md).

```csharp
public static implicit operator Vector3(Vector2 v)
```

### Parameters

**** (\[Vector2]\(/engine/6000.6/script-reference/unityengine/vector2)): The Vector2 to convert.

### Returns

| Type                                                              | Description |
| ----------------------------------------------------------------- | ----------- |
| [Vector3](/engine/6000.6/script-reference/unityengine/vector3.md) |             |

### Remarks

A [Vector2](/engine/6000.6/script-reference/unityengine/vector2.md) can be implicitly converted into a [Vector3](/engine/6000.6/script-reference/unityengine/vector3.md). (The z is set to zero in the result).

### Examples

```csharp
using UnityEngine;

public class ExampleScript : MonoBehaviour
{
    void Start()
    {
        Vector2 v2 = new Vector2(1, 2);
        Debug.Log("Vector2 is: " + v2);

        // convert v2 to v3
        Vector3 v3 = v2;
        Debug.Log("Vector3 is: " + v3);

        // convert v3 to new Vector3
        Debug.Log("Set v3 to (3, 4, 5)");
        v3 = new Vector3(3, 4, 5);

        // convert v3 to v2
        v2 = v3;
        Debug.Log("Vector2 is: " + v2);
    }
}
```
