As I journey down this Unity-fying road, I weave together many strands left behind by those adventurers that have come before me.
That’s a nice way of saying that I stick together pieces of code found on n00b boards.
In any case – I have a game wherein I’ve replaced the default cursor with an object on the game world. I’d hoped that the cursor I saw while playing the game in the editor would disappear once I’d built it, but alas no.
There are several pieces that were recommended in order to achieve a cursor-less performance – let’s look at them in no particular order. Some of them are bound to help. I guess.
Just hide the bleepin’ cursor
This one was one of those “Ahah!” moments. Simply pick an appropriate position in any of your Start() methods, and add
Screen.showCursor = false;
Voila! The cursor disappears. Or does it? Those of us on a Mac, and others as well I believe, will find that with enough scrolling around the cursor reappears. Even more annoyingly, it refuses to disappear, even if you hide the cursor on every update. What to do?
The next pearl of wisdom I stumbled across said to add another line to the previous line hiding the cursor.
Screen.lockCursor = true;
I’d hoped this would lock the cursor to some sort of game space, preventing it from violating its boundaries. Unfortunately, this line locks the cursor to the centre of the screen. Perfect if your game doesn’t use a mouse, less perfect in my case. I scratched this one, but it might work for you.
Just fix the settings already.
It turns out that there is a setting in the build properties that allow you to turn off the dock on OSX. That’s neat.
Just go to File -> Build Settings. Click on Player Settings and a menu will appear on the right hand side.
Third from the bottom, there’s an option saying Mac fullscreen mode, which defaults to full screen with dock. Change that to full screen (implicitly without dock) and your build is suddenly cursor free.