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
- Crash on JobQueue::HasJobGroupIDCompleted when closing the Editor while in Play mode on a specific project
- In "Preferences" section the “SpriteShape” menu item, the details page title “SpriteShape”, and “ControlPoint” entries are displayed as code strings rather than formatted UI strings
- Errors thrown constantly when Virtual Offset Debug is enabled and lighting was baked on AMD machine
- Persistent Memory Leak when reloading domain and using Distance-based Ghost Importance
- HDRP project doesn't render in standalone player when using High stripping
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