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 Reappears at Random

Discussion in 'macOS' started by BrainAndBrain, Dec 5, 2016.

  1. BrainAndBrain

    BrainAndBrain

    Joined:
    Nov 27, 2014
    Posts:
    115
    Hi all,

    My game is running in Full Screen by default, and my "Mac Fullscreen Mode" in Player Settings is set to "Fullscreen Window with Menu Bar and Dock." These are the settings I want to use, as they're the most standard and user-friendly.

    I'm hiding the system cursor like so:

    Cursor.visible = false;
    However, the system cursor will often come back, either at random, or when moving the the cursor up into the menu bar or down into the dock. I would expect it to return when going to one of these sections, but it never disappears again; Cursor.visible is still set to false, despite the cursor clearly being visible.

    The only workaround I've found is to create an empty texture and set it as the "Default Cursor" in Player Settings. Thus, the system cursor is being replaced by the empty texture, and will not be drawn while the game is active. Unfortunately, the cursor will not even be drawn when you move it up to the menu bar or down to the dock. Apple wasn't a fan of this, so at their request I left "Default Cursor" set to None, and right now Mac App Store players have to deal with the cursor randomly coming back. (Of course, Apple doesn't like that the cursor randomly appears, either. It's lose-lose.)

    This is an extremely common issue that I've noticed in most (all?) major Unity games on Mac (Kentucky Route Zero comes to mind). Has anyone found a workaround? Is this a bug?

    Thanks!

    - David
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,398
    It should work if you set Cursor.visible to false every frame.

    --Eric
     
    VIC20 likes this.
  3. BrainAndBrain

    BrainAndBrain

    Joined:
    Nov 27, 2014
    Posts:
    115
    Alas, I tried that with no luck.
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,398
    Hmm, well, that was my only idea. ;) Just for the record, I dislike Fullscreen Window with Menu Bar and Dock, and find the menu and dock popping up when moving the mouse around really annoying. Fullscreen Window is basically fine...it's true it doesn't allow Command-Tab, but you can always Command-F to toggle windowed mode, so it's not much of an issue.

    --Eric
     
  5. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,840
    Instead of Cursor.visible = false, have you tried Screen.lockCursor = true?
     
  6. BrainAndBrain

    BrainAndBrain

    Joined:
    Nov 27, 2014
    Posts:
    115
    @Eric5h5 : I'll keep Fullscreen Window in mind. It's not exactly the solution I'd like, but it gets me most of the way there. Thanks!

    @JoeStrout : Looks like Screen.lockCursor is obsolete, though I could use Cursor.lockState. I'm using Input.mousePosition to map my in-game cursor however, so I'd have to switch to Input.getAxis or something in order to make that work. It's something to consider. In the meantime, I'll file a bug report since this is really easily repeatable.
     
    JoeStrout likes this.
  7. BrainAndBrain

    BrainAndBrain

    Joined:
    Nov 27, 2014
    Posts:
    115
  8. BrainAndBrain

    BrainAndBrain

    Joined:
    Nov 27, 2014
    Posts:
    115
    Quick update to say the the bug was reproduced and forward to the Unity devs on 12.7. I'm not sure if there is a fix or if it has made it into a recent update.
     
  9. BrainAndBrain

    BrainAndBrain

    Joined:
    Nov 27, 2014
    Posts:
    115
    Another quick update to say that the bug is still present in Unity 5.5.2p2. Contacted Unity about it, but haven't heard back yet.
     
  10. Oyshoboy

    Oyshoboy

    Joined:
    Jan 6, 2017
    Posts:
    20
    Have you solved the issue? This things is really annoying and still persist