Search Issue Tracker
By Design
Votes
0
Found in
2019.4.39f1
2020.3.37f1
2021.3.7f1
2022.1.11f1
2022.2.0b3
2023.1.0a4
Issue ID
UUM-10009
Regression
No
Cursor.visible does not take effect when disabling and enabling the GameObject with the Script attached
Reproduction steps:
- Open the attached project
- Open the “/Assets/Qa/Tests/KeyboardMouseBasic/ISX_KB_Mouse_Basic.unity” Scene
- Enter the Play Mode
- Click anywhere in the Game View
- Enable or Disable the “CursorHide” GameObject
- Click anywhere in the Game View
- Repeat the 5 and 6 steps and observe the cursor’s behavior
Expected result: The cursor doesn’t hide after enabling the “CursorHide” GameObject the second time
Actual result: The cursor hides after enabling the “CursorHide” GameObject the second time
Reproducible with: 2019.4.39f1, 2020.3.37f1, 2021.3.7f1, 2022.1.11f1, 2022.2.0b3, 2023.1.0a4
Reproducible on: Windows 10 (21H2), M1 MacOS 12.4 (21F79)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Channel remapping dropdown in the Terrain Layer does not open when clicked on the title
- The Editor freezes indefinitely when a large number of elements are entered in the Subgraphs or Categories lists
- Some Visual Effects package Assets links to documentation are not working
- Heatmap asset’s documentation button in the Inspector window leads to “Sorry... that page seems to be missing!” page when clicked
- Crash on MonoBehaviour::CallMethodIfAvailable when performing various actions
Resolution Note:
I tested the project given but was unable to reproduce the issue. What I saw was that the cursor was hidden in all cases when the Unity Game View had focus (i.e. after clicking in the game view).
It is always hidden because the cursor lock state is set to CursorLockMode.Locked in CursorLock.cs and this will always hide the cursor regardless of the visible state:
https://docs.unity3d.com/ScriptReference/Cursor-lockState.html
https://docs.unity3d.com/ScriptReference/Cursor-visible.html
When I toggled the CursorLockMode.None using the Space bar, then I saw the expected result which was that the cursor was hidden the first time the CursorHide object was enabled and didn't hide on the second or third attempts to enable the component. The Start() function only triggers once, so enabling and disabling the component should not trigger any behaviour in CursorOff.cs or CursorLock.cs a second time.
https://docs.unity3d.com/Manual/class-MonoBehaviour.html