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:

  1. Open the attached project
  2. Open the “/Assets/Qa/Tests/KeyboardMouseBasic/ISX_KB_Mouse_Basic.unity” Scene
  3. Enter the Play Mode
  4. Click anywhere in the Game View
  5. Enable or Disable the “CursorHide” GameObject
  6. Click anywhere in the Game View
  7. 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)

  1. 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

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.