Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Cursor.visible - is this a bug??

Discussion in 'Scripting' started by jleven22, Oct 19, 2020.

  1. jleven22

    jleven22

    Joined:
    Mar 26, 2019
    Posts:
    421
    I'm currently trying to use:

    Code (CSharp):
    1.     void Start()
    2.     {
    3.         Cursor.visible = false;
    4.     }
    The console is printing this error:

    Assets\Scripts\Cursor.cs(9,16): error CS0117: 'Cursor' does not contain a definition for 'visible'

    Just upgraded to 2020. Could this be a new bug?
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,893
    It's because you named your class "Cursor". So any reference to "Cursor" is using your Cursor class, not Unity's.

    To get around this:
    • Use
      UnityEngine.Cursor.visible
    • Rename your class
     
    Bunny83 likes this.
  3. jleven22

    jleven22

    Joined:
    Mar 26, 2019
    Posts:
    421
    FACE.
    PALM.
    THX.
     
    Bunny83 and PraetorBlue like this.