Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Cursor not disappearing when play testing in Editor

Discussion in 'Editor & General Support' started by DaPizzaKing, Nov 30, 2017.

  1. DaPizzaKing

    DaPizzaKing

    Joined:
    Jan 14, 2016
    Posts:
    9
    Most people complain about the mouse cursor disappearing when they play, because it's a necessity for their type of game.
    My personal problem is that when launching the game (or play testing) in the Unity Editor, the mouse won't go away. I need it to go away so I can easily have access to my mouse buttons without clicking on anything out of the game itself. It's a problem because I use the mouse to look around and, in the process of looking around, my mouse moves out of the game window which then leads to me clicking on things outside of the game itself.
    I'm sure you understand how this is a problem. Any help would be appreciated, thank you.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You're probably interested in both Cursor.visible and Cursor.lockState. Cursor.visible is just what it says, and Cursor.lockState lets you lock the mouse cursor to the window, to the center of the window, not at all, etc.

    https://docs.unity3d.com/ScriptReference/Cursor-visible.html
    https://docs.unity3d.com/ScriptReference/Cursor-lockState.html

    My guess is you will want to set Cursor.lockState to Locked, which makes it invisible anyway and stuck in the center of your window so you can't click off of it by accident.
     
    Last edited: Nov 30, 2017
  3. zachseven

    zachseven

    Joined:
    Dec 18, 2016
    Posts:
    15
    If you have PlayMaker installed and PlayMakerGUI in your hierarchy it defaults to controlling the mouse cursor. Untick the box in the inspector that says 'Control Mouse Cursor'.
     
  4. Sarun_Ratta

    Sarun_Ratta

    Joined:
    Mar 26, 2015
    Posts:
    8
    Thanks a lot. It works for me.