UNT0035 A Vector2 can be converted into a Vector3.

March 28, 2023 ยท View on GitHub

A Vector2 can be converted into a Vector3. (The z is set to 0).

Examples of patterns that are flagged by this analyzer

using UnityEngine;

class Camera : MonoBehaviour
{
    private void Update()
    {
        Vector3 v3 = ...;
        Vector2 v2 = ...;
        var distance = Vector3.Distance(v3, new Vector3(v2.x, v2.y, 0));
    }
}

Solution

Use built-in conversion:

using UnityEngine;

class Camera : MonoBehaviour
{
    private void Update()
    {
        Vector3 v3 = ...;
        Vector2 v2 = ...;
        var distance = Vector3.Distance(v3, v2);
    }
}

A code fix is offered for this diagnostic to automatically apply this change.