Search Unity

Cursor.visible not working? (5.0)

Discussion in 'Scripting' started by LaneFox, Mar 4, 2015.

  1. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,519
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class cursorTest : MonoBehaviour {
    6.  
    7.     // Use this for initialization
    8.     void Start () {
    9.         Cursor.visible = false;
    10.     }
    11.  
    12.     // Update is called once per frame
    13.     void Update () {
    14.  
    15.     }
    16. }
    17.  
    Screen.showCursor (depreciated) redirects to Cursor.visible, but doesn't seem to hide the cursor?
     
    Last edited: Mar 4, 2015
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Works fine here.

    --Eric
     
  3. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,519
    Ahhh. Has to run in Update/GUI...
     
    rmele09 likes this.
  4. peterpantss

    peterpantss

    Joined:
    Sep 24, 2014
    Posts:
    13
    I've ran it in Update() and OnGUI() and it likes to flicker on/off while testing in editor. Build mode works fine though.
     
    apilatosba likes this.
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    It works in Start here.

    --Eric
     
  6. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,519
    Thats odd.

    On the hardware I used it doesn't work in Start() at all in the Editor or Build.
     
  7. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    What hardware is that? It works in Start in the editor and a build here (Mac Pro, 10.9.5).

    --Eric
     
  8. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,519
    I'm on my work computer with Win 7 64bit (7601) and Radeon HD 6450. Also changed my Win themes around in case that was interfering somewhow, but wasn't. Will test later at home with a different GPU.

    I don't have a Mac to test on.
     
  9. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,519
    Asked around and got some mixed results, another user confirming what I see is using Win7 / GTX 570.
     
  10. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,411
    (came here from google..)

    just to add, using U5.0.0p3,

    Inside editor:
    - With Start() {Cursor.visible = false;}, have to click once to hide cursor (it's initially visible)

    Same code in build (exe, win7)
    - Cursor is hidden at start
     
    apilatosba, barry7575 and GorgCreater like this.
  11. Cherno

    Cherno

    Joined:
    Apr 7, 2013
    Posts:
    515
    Win7, didn't test it in a build, but in the Editor it just flickers but stays mostly visible, no matter if done in Start and/or Update.
     
  12. Jokerrr

    Jokerrr

    Joined:
    May 21, 2014
    Posts:
    1
    Cursor.visible = false; doesn't work if i change Time.timeScale is there any other options to disable mouse?
     
  13. boylec

    boylec

    Joined:
    May 28, 2015
    Posts:
    4
    Make sure you don't have Cursor.lockMode in the update function either, it will cause the cursor to flicker. Put Cursor.lockMode = Cursor.Locked (or whatever property you want) and Cursor.visible = false all in the Start() function.
     
  14. imDanOush

    imDanOush

    Joined:
    Oct 12, 2013
    Posts:
    368
    Guys, I have Win8.2 and used this code:

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class Crosshair : MonoBehaviour {
    6.  
    7.     // Use this for initialization
    8.     void Start () {
    9.         Cursor.visible = false;
    10.     }
    11.  
    12.     // Update is called once per frame
    13.     void Update () {
    14.     }
    15.  
    16.     void Awake() {
    17.  
    18.     }
    19. }
    20.  
    Mouse hides in the scene view but does not hide in the game view, this should be vice versa!!

    EDIT: If I maximize game view, it'd work fine.
     
  15. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    476
    It seems to be simply completely broken on PC.
     
  16. dizzymediainc

    dizzymediainc

    Joined:
    Apr 6, 2014
    Posts:
    433
    I am having the same issue as well, I even tried to replace the cursor with a 2D texture that is blank and it still doesn't switch over :(
     
  17. Robdon

    Robdon

    Joined:
    Jan 10, 2014
    Posts:
    141
    Same happens for me.

    If you restart Unity, and run with Cursor.visible = false; in Start(), it works the first time you run the project.

    If you stop it, and then run again (without closing Unity), it wont hide the cursor until you click in the Game view window once.
     
    Last edited: Aug 2, 2015
  18. Slight0

    Slight0

    Joined:
    Dec 6, 2013
    Posts:
    28
    Settings Cursor.visible = false won't work in the editor. Apparently it's a bug with unity that has been reported for over six months and still no fix. Doubt you'll get one in another six months.

    Build mode works fine; something in the editor code is unhiding the cursor every frame.
     
    LeandroExHuMeD likes this.
  19. dizzymediainc

    dizzymediainc

    Joined:
    Apr 6, 2014
    Posts:
    433
    i managed to fix it, i replaced the cursor with a blank cursor and it works fine, locks it to center, etc.
     
  20. MS80

    MS80

    Joined:
    Mar 7, 2014
    Posts:
    346
    This issue still exists! "Cursor.visible" is not working correctly!

    If I use it in "Start" the cursor does not dissappear, if I use it in "Update" the cursor flickers (editor and build)!

    Replacing with blank texture and locking the cursor is the only way it works for me so far!

    Using Unity 5.1.2p3 (Win7 64bit, GTX 670)
     
    Last edited: Sep 7, 2015
  21. Haze-Games

    Haze-Games

    Joined:
    Mar 1, 2015
    Posts:
    189
    Hey guys,
    I had the same issue as you all, my cursor was flickering in builds. Terrible!
    It seems like as soon as the cursor moves on the screen, it flickers with Cursor.visible = false;

    To hide the cursor correctly in build, you need to do this:

    Code (CSharp):
    1. // Prevent cursor from moving to avoid flickering
    2. Cursor.lockState = CursorLockMode.Locked;
    3. // Hide the cursor
    4. Cursor.visible = false;
    To re-enable it:

    Code (CSharp):
    1. // Allow it to move on the screen
    2. Cursor.lockState = CursorLockMode.Confined;
    3. // Show the cursor
    4. Cursor.visible = true;
    The hidden cursor is still broken in the Editor.

    Cheers,
    Aze.
     
    awesomedata likes this.
  22. jinnindo

    jinnindo

    Joined:
    Dec 8, 2015
    Posts:
    17
    This is still a problem in 5.3 and 5.4.
    Sometimes works/won't in editor or builds, flickers when it does.

    I keep running into bugs that are marked as fixed. It's burning me out.
     
    awesomedata likes this.
  23. HowPrice

    HowPrice

    Joined:
    Jan 22, 2016
    Posts:
    36
    We have to call Cursor.visible=false; every frame to keep the cursor from re-appearing.

    It seems as though *something* is setting it to be visible, but there are no calls that I can see, and of course I can't set a data-breakpoint to find out the cause.
     
    PNUMIA-Rob likes this.
  24. LeifHeaney

    LeifHeaney

    Joined:
    Nov 9, 2015
    Posts:
    1
    I believe I've found the answer. Under your FPSController, assuming you're using Unity Standard Assets, there is the MouseLook portion of the First Person Controller script. Within that portion is a box that is automatically checked when you use the FPSController prefab. The box is labeled "Lock Cursor." Uncheck that box and see if it works for you.
     
  25. QwaKlak

    QwaKlak

    Joined:
    Jun 19, 2016
    Posts:
    1
    I know what's a problem , i get the same .
    You have Script in Scean which name is "Cursor". You have to make new scritp with other name . And now you can use Cursor.dotdotdot
     
  26. joaobsneto

    joaobsneto

    Joined:
    Dec 10, 2009
    Posts:
    152
    I have the same issue. I found that playmaker is affecting the cursor.

    I use this two line codes:

    PlayMakerGUI.LockCursor = true;
    PlayMakerGUI.HideCursor = false;

    But the cursor starts blinking.
     
  27. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    (Edit: See below post.)
     
    Last edited: Feb 8, 2017
  28. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    Looks like this only works with the game view active, and hiding the cursor in the scene view is impossible.

    What the heck, Unity? I'm trying to program an editor tool here! It'd be nice to have control of at least the visibility of my cursor!
     
  29. ruft

    ruft

    Joined:
    Aug 1, 2017
    Posts:
    1
    Thanks LeifHeaney. That solved the problem for me.
     
  30. Overnaut

    Overnaut

    Joined:
    Aug 25, 2017
    Posts:
    19
    Does not work for me since I use not an CharacterController but a rigitBody with an own turn and look around script which works fine. When I use the Update or onGUI method:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class GroundOnClick : MonoBehaviour
    6. {
    7.     public GameObject menuCanvas; // Menu canvas object
    8.  
    9.     public void Awake(){
    10.         menuCanvas = GameObject.Find ("MenuCanvas");
    11.     }
    12.  
    13.     public void Update () {
    14.        
    15.     }
    16.  
    17.     void OnGUI(){
    18.         Cursor.visible = menuCanvas.activeSelf;
    19.         Cursor.lockState = menuCanvas.activeSelf ? CursorLockMode.Confined : CursorLockMode.Locked;
    20.     }
    21. }
    my cursor is always hidden. Working on Ubuntu 17.04, Unity for Linux 2017.2.0.xb6.
     
  31. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    Try taking your Cursor.visible out of the OnGUI() area and replacing it with a bool that changes only when necessary. OnGUI fires like a billion times a second -- it's possible the OS just can't handle that kind of multiple-times-per-frame update?

    If that's not the case, you could try "if menuCanvas.activeInHierarchy == true then ..." since "activeSelf" only works for the root parent of a gameobject. It's possible activeSelf retains the value of a previous use as well, but I don't know it's exact behavior -- especially when called multiple times per frame, and if this is an editor script, that just adds more uncertainty to its behavior without testing.

    I eventually had to use the tool commands for my cursor issue, but mine was an Editor script.
     
    zenraikou likes this.
  32. Overnaut

    Overnaut

    Joined:
    Aug 25, 2017
    Posts:
    19
    Thanks for your reply, I tried it but it does not work.
    Code (CSharp):
    1. menuCanvas.activeInHierarchy
    is always active. I have read the manuals on Input, Canvas, Camera, activeSelf, activeInHierarchy, onMouseOver, -Down, but I guess I don't know enough. Any tutorial, reference, and explanation is highly appreciated. My setup is:
    Code (CSharp):
    1. Character (Layer Player)
    2.     |--Main Camera
    3.         |--MenuCanvas (Layer UI, default layer brings zero changes)
    4.             |--8 Spheres (Layer UI, Sphere Collider active, Is Trigger = true)
    The character moves around, turns are applied to the character, and looking is applied to the camera from this tutorial and works fine. The
    Code (CSharp):
    1. MenuCanvas.SetActive(false)
    is called on the Awake() method in a script to hide the canvas, when I click on the ground
    Code (CSharp):
    1. MenuCanvas.SetActive(true)
    is set and shows the canvas with the render mode set to screen space - camera. Furthermore the cursor has the following influence:
    Code (CSharp):
    1.  
    2. public void Update () {
    3.             Cursor.lockState = menuCanvas.activeSelf ? CursorLockMode.Confined : CursorLockMode.Locked;
    4.             Cursor.visible = menuCanvas.activeSelf;
    5.     }
    6.  
    So if the menuCanvas is active, the cursor should appear on screen, be moved freely inside the screen, and should trigger the following methods of the 8 sphere scripts:
    Code (CSharp):
    1.  
    2. void OnMouseDown(){
    3.     Debug.Log ("Mouse down on sphere");
    4.     menuCanvas.SetActive(false);
    5.     }
    6.  
    7.     void OnMouseOver(){
    8.         Debug.Log ("Mouse over");
    9.     }
    10.  
    But the reality is that the cursor is hidden and the 8 spheres do not receive any user input. Also when I change the usage of GameObject
    Code (CSharp):
    1. menuCanvas.activeSelf
    to
    Code (CSharp):
    1. menuCanvas = GameObject.Find ("MenuCanvas").GetComponent<Canvas> ();
    to use the menuCanvas.enabled bool. When I change the CursorLockMode.Confined to None, the cursor appears on screen, but still the spheres do not receive any events on their methods.

    The sphere collider radius is as big as the sphere which has the z value of zero, the spheres should not be behind the canvas right? However, -10 or -100 z values do not change anything.

    What am I missing or doing wrong, I don't get it. The EventSystem is in the scene, all the envolved objects have their scripts assigned, I just want to receive some events on the spheres, eventually even with the confined cursor lock mode.

    Should I use raycasts? I came to the idea because of this post.
     
  33. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    There's a few issues it seems, at least at first glance, otherwise i may not be following you.

    First, and mainly, you should probably use OnEnable() instead of Awake() to do things with activation/deactivation of gameobjects.

    Secondly, as mentioned previously, activeInHeirarchy is what you need if your gameobject has ANY parent when activating and deactivating. Also, keep in mind gameobject variables and values used to be reset between activations, keeping none of the stuff you set, since the gameobject is effectively destroyed and recreated upon activating/reactivating, so trying to deactivate something, especially before its Start() event is called using Awake() could be part of your issue.

    Hopefully that helps a little.

    As far as canvas stuff goes, it uses the UI layer to process its events, so be sure the UI layer doesn't accept collision events from other layers, and vice versa for the layer you're trying to click on with the spheres, (though you could potentially use gizmos and handles for the spheres to make your life simpler, as i want to say these can be drawn in the game view too if done properly!)
     
  34. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    Using any of the Find* variants in Awake is a big no no. Since most of these Find functions only returns an object if they exist and is active, it's likely you could be running into a race condition where this object "awakes" first before the other object you're trying to find.

    Move all Find related code to Start() instead.
     
    awesomedata likes this.
  35. Overnaut

    Overnaut

    Joined:
    Aug 25, 2017
    Posts:
    19
    I replaced all Awake methods with Start I get the following error:
    The method looks like this:
    Code (CSharp):
    1.     void OnEnable(){
    2.         gameCube.SetActive (false);
    3.     }
    I replaced Start with Awake again and the error is gone, but the Start method works in other scripts, thank you.

    I use now the OnEnable() method and activeInHierarchy instead of activeSelf, the
    Code (CSharp):
    1.  
    2. void OnEnable(){
    3.   menuCanvas.SetActive(false);
    4. }
    5.  
    method gives me the error that menuCanvas is unassigned. Moving the body of OnEnable() into Start() works fine.

    Extremly good to know thanks a ton! This also applies to:
    I removed the UI layer for now, does not change anything. I'm know back at my problem, when I click on the ground the canvas appears but the spheres in the canvas do not receive any user input.

    It is easier if you guys can check and see it for yourself, here the project with commented code as a .zip:
    http://turbobit.net/01u02drppqtr.html
    If someone stumbles alter on this link, it is 7 days availiable.
     
  36. Overnaut

    Overnaut

    Joined:
    Aug 25, 2017
    Posts:
    19
    I figured it out, put the canvas to overlay and not as a child of camera, then I used OnEnable and OnDisable methods for the Cursor. Not exactly what I wanted, but the tradeoff is okay.
     
    awesomedata likes this.
  37. GarrettCMiller

    GarrettCMiller

    Joined:
    Jan 20, 2013
    Posts:
    30
    I have to say I'd had this problem for a while but joaobsneto's post about Playmaker helped me! I just fixed it by clicking the PlaymakerGUI object in my scene view and unchecking "Control Mouse Cursor". Don't know why that is enabled by default but it's extremely irritating. This may not help everyone, but anyone with Playmaker, CHECK THIS.
     
    jason07 and joaobsneto like this.
  38. PNUMIA-Rob

    PNUMIA-Rob

    Joined:
    Jan 7, 2015
    Posts:
    33
    Experiencing this very same thing in 2017.1.1f1 and it's super annoying, not only that but Cursor.lockstate also seems to be getting reset each frame so unless it's being set constantly the cursor does not lock -- but that makes the cursor flicker. I suspect that these are symptoms of the same bug and it would be REALLY nice if it could get fixed or someone could post a clear work around.
     
  39. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    Seems like this is the issue -- Unity Team needs to stop developing the Windows client on Macs. lol
     
  40. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    Are you on Windows or Mac?


    I do want to shout out to the half-joke I made in my previous post -- issues like these (from things that were considered "fixed" to some and then "not-fixed" to others) I'm willing to bet come from the Unity Engineers' choice of OS alone.

    Coming from a hardware technician background myself, I've noticed Macs are super-pretty but also super NOT Windows too. No hardware technician I've ever known enjoys working on them. Why? Because they can be quite unpredictable (and buggy) on the software/memory/persistent data side. In many cases today, due to the "black-box" software style, Macs are actually MORE unpredictable than Windows. This is especially true when they try to do "Windows-like" things.

    In the end, relying on Macs to develop the code to produce the proper behavior on a Windows platform (especially for the Unity editor itself) is not only a crutch, but also a BAD IDEA to the undisputed majority of users -- users who own a PC. Instead, the Unity Team should heavily consider the standard practice of programming on a PC and /then/ porting that to a Mac.


    @Unity:

    Yeah, I know, it won't be quite as pretty to work with moment to moment, but the workarounds on Windows to ease the "less pretty" nature of the Windows OS are numerous, while the workarounds from "user-land" to fix niggling little (huge) issues creeping over to Windows from Mac-development machines (like the "Cursor visibility issue that "looks" fixed on Mac, but is actually broken on PC in some cases) are simply non-existent in most times.

    Most users don't complain about this stuff because there are other more pressing issues in Unity that they're trying to work around, so if you do hear a complaint like this -- it might be wise to take it seriously. There's probably a major productivity/usability issue hiding somewhere in there. I won't even mention the "Mixed Line Endings" errors Windows users get from Unity's native code samples for this reason (because it is MS's fault it's not intuitive/fast to fix this in VS), but because you guys refuse to make other tiny stuff of this nature easier for us (by changing tiny things in places WE can't), it amounts overall to one (huge!) PITA for the vast majority of your users when all this combines -- and it makes us feel like you just don't care.
     
    Last edited: May 1, 2018
  41. gpvusername

    gpvusername

    Joined:
    Feb 3, 2017
    Posts:
    2
    amen
     
    awesomedata likes this.
  42. gpvusername

    gpvusername

    Joined:
    Feb 3, 2017
    Posts:
    2
    err i just moved the Cursor.visible = false; to my player object and it works.. for me anyway. woohoo. kind of.
     
  43. easterbunnie228

    easterbunnie228

    Joined:
    Jan 31, 2017
    Posts:
    2
    For those having issues with mouse flickering after using cursor.visible(false or true). I assume you are using the FPS controller provided with Unity. You need to change some code within the FPS controller to fix that issue.

    What I did to stop my flickering mouse: First off, I want to say that I was making a pause menu. So when I pause the game, Time.timeScale = 0; etc. However, I wanted my cursor to stay visible even after pressing a UI button. So I used cursor.visible to set when I want the cursor to be visible. This worked for the most part, except my cursor kept jumping back to the center of the screen. After looking at a few discussion boards(including this one), I decided to move on and I can live with the flickering for now. Cause, after all, Many people were saying that it would still work after the build of the game. My next order of business was to stop my FPS Controller's camera from moving while the game is paused. To do so, I needed this using directive in my script used to access the pause menu:

    using UnityStandardAssets.Characters.FirstPerson;

    Using this directive allows your script to access information in the FirstPersonController script.

    Next, I opened the FPC script. To find it: Standard Assets folder > Characters > First Person Character > Scripts

    Then, I added a static boolean to turn on and off the ability to look around. The code you need to restrict is under the RotateView() method. It should be around line 239 240.

    Static bool example: public static bool stopRot;

    If statement to stop rotation example: if(!stopRot){ m_MouseLook.LookRotation (transform, m_Camera.transform); }

    Finally call the boolean in your original script like so: FirstPersonController.booleanName = false/true;

    EXAMPLE: FirstPersonController.stopRot = true;

    This stops the camera from rotating while paused, AND stops the cursor from going back to the center of the screen, allowing for free movement in the UI menus.

    HOPE THIS HELPS!!!
     
  44. RealPpTheBest

    RealPpTheBest

    Joined:
    Jan 27, 2019
    Posts:
    64
    I use this script in my project everytime.. use it any scene required.. To use, just attach this script to an empty gameobject and click on the bool you want to set active. This script only changes the cursor state/visibilty for the scene this script is attached in.. You can use this script in as many scenes, you want.

    Code (CSharp):
    1. //Script written by Pratyush Priyadarshi.
    2.  
    3. using UnityEngine;
    4. using System.Collections;
    5. using System.Collections.Generic;
    6.  
    7. public class CursorVisible : MonoBehaviour {
    8.  
    9.     [TextArea]
    10.     public string Infomation = "Tick the bool which is required. If you want to change a bool mid-game while running the test mode, double click the active bool to disactivate it and then proceed further and check your desired bool.";
    11.  
    12.     [Space(20)]
    13.  
    14.     public bool isVisible = true;
    15.     public bool isInvisible = false;
    16.  
    17.     void Start() {
    18.         Cursor.visible = true;
    19.     }
    20.  
    21.     void Update()
    22.     {
    23.         if (isVisible == true){
    24.             isInvisible = false;
    25.             if (Cursor.visible == false)
    26.             {
    27.                 Cursor.visible = true;
    28.             }
    29.             else
    30.             {
    31.                 Cursor.visible = true;
    32.             }
    33.         }
    34.         if (isInvisible == true){
    35.             isVisible = false;
    36.             if (Cursor.visible == true)
    37.             {
    38.                 Cursor.visible = false;
    39.             }
    40.             else
    41.             {
    42.                 Cursor.visible = false;
    43.             }
    44.         }
    45.     }
    46. }
    Hope it helps!

    Cheers!
    PpTheBest
     
    Vincent454 likes this.
  45. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,519
    I could have had 3 kids between your post and mine.
     
    Rewaken, Ryiah, awesomedata and 2 others like this.
  46. RealPpTheBest

    RealPpTheBest

    Joined:
    Jan 27, 2019
    Posts:
    64
    XD. Ikr. I actually got into programming last year and found this page yesterday, so just answered this question for people who have this problem right now.. and it could even help people in the future.. Btw, I can't stop laughing... XD
     
  47. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Um. That code is...extremely suboptimal, though. ;) Way too many unnecessary variables and extraneous code that shouldn't exist and does nothing.

    Code (csharp):
    1. using UnityEngine;
    2.  
    3. public class CursorVisible : MonoBehaviour {
    4.  
    5.     [Tooltip("Whether the cursor is visible, duh")]
    6.     public bool isVisible = true;
    7.  
    8.     void Update() {
    9.         Cursor.visible = isVisible;
    10.     }
    11. }
    Which, incidentally, is what LaneFox said in the third post back in 2015. (Still works fine in Start here, but setting it in Update is not exactly going to kill the framerate.)

    --Eric
     
    Ryiah likes this.
  48. Jiaquarium

    Jiaquarium

    Joined:
    Mar 22, 2020
    Posts:
    45
    in Unity 2018.4, I had to switch Resolution Fullscreen Mode to "Exclusive Fullscreen" under Build Settings > Player Settings for Cursor.visible to work.
     
  49. aveakrause

    aveakrause

    Joined:
    Oct 3, 2018
    Posts:
    70
    So I was able to get Cursor.visible working for the most part... Except sometimes when I set it to false, it reads as false properly but the cursor still displays.

    How the heck can Cursor.visible be false but still display the hardware cursor??? Unity whyyyyy

    I think it's because I change it to true, then back to false within the same frame. I use a file browser to load up a save file, need hardware pointer for that, this is blocking. When the user confirms, then the block is released and the frame continues it hides the hardware cursor again and displays the virtual cursor... Except that even though it properly sets Cursor.visible to false, the hardware cursor doesn't go away.
     
    apilatosba and awesomedata like this.
  50. baraterahul48

    baraterahul48

    Joined:
    Jun 20, 2021
    Posts:
    3
    Thank You, this one worked for me