Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug Physics Raycaster requires restart

Discussion in 'UGUI & TextMesh Pro' started by georgeq, Jun 25, 2021.

  1. georgeq

    georgeq

    Joined:
    Mar 5, 2014
    Posts:
    640
    Unity 2020.2.2f1

    I'm using the Physics Raycast to drag an object on my scene, the problem is that OnBeginDrag is only called after I click several times with the mouse over the object I want to drag. It does sometimes (very rarely) get called at the first attempt, so I think there might be a bug.

    PhysicsRaycast.cs contains a function named ComputeRayAndDistance which has 3 exit points that return false, in which case the corresponding event is not triggered. The last statement returns true, in which case the event is triggered. I tried to add some Debug statements to see what was happening, but unsurprisingly the file is write-protected, and you're not allowed to change its permissions either. So the only way to get a grasp of what happens is by placing breakpoints. If I set breakpoints on each of the return statements, execution never stops, as if the function was never called, but if set a breakpoint at line 122 which is used to test if the mouse is inside the camera's rectangle, execution stops immediately as soon as I do something with the mouse. Once the execution stops, if I disable all breakpoints and continue, I start receiving all the events for which I have interfaces implemented.

    Restarting Unity solves the problem.

    [UPDATE]
    This happens when Windows wakes up from hibernation. To reproduce just leave Unity open, put the computer to hibernate, and then wake it up.
     
    Last edited: Jun 27, 2021