Vector2.zero does not exist

Hey Guys,

I am new to scripting in Unity and doing the Getting Started Tutorial from the Unity learn page.
I am trying to change the mouse cursor when hovering over a GameObject.
Everthing is fine, but when I am trying to initialize a zero Vector with new Vector2.zero Visual Studio says that "The type name ‘zero’ does not exist in the type ‘Vector2’. If I am just using new Vector2(0,0) it is working fine.
Basically this is not much of an issue but I would like to use the shortcuts if they are there.
Does anyone else have this problem or know what could be the issue here?
I am using VisualStudio 2019
Here is the full code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{

   
    // What objects are clickable
    public LayerMask clickableLayer;

    // Swap cursor if clickable
    public Texture2D cursor; // Normal cursor
    public Texture2D instrument; // Cursor for clickable instruments like a cannon




    // Update is called once per frame
    void Update()
    {
        //Raycast script to determine where in the Gameworld you are pointing
        RaycastHit hit;

        if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 50, clickableLayer.value))
        {
            // Change the mousecursor if you hit an "instrument" object
            bool isInstrument = false;
            if(hit.collider.gameObject.tag == "Instrument")
            {
                Cursor.SetCursor(instrument, new Vector2(16, 16), CursorMode.Auto);
                isInstrument = true;
            }
        }
        else
        {
            Cursor.SetCursor(cursor, new Vector2.zero, CursorMode.Auto);
        }
    }
}

Here are some images from my IDE:

Have you tried leaving the “new” keyword away?
You EITHER call the constructor with new Vector2() OR you use a preset (like zero, left etc). Not both at the same time.

The problem is that you have the keyword “new” in front of Vector2.zero. When you write “new”, the compiler expects the next word to be a type, and Vector2.zero is not a type- rather it is a property.

You are right, I had to leave the ‘new’ out and that solved the problem. Thank you very much :slight_smile: