When raycasting UI with EventSystem, Unity returns distance value not from camera center, but from near clip plane. This can be fixed in FocusManager, when converting from camera space to worldSpace add nearClipPlane to the distance. This fixes the issue. See
https://issuetracker.unity3d.com/issues/incorrect-distance-is-returned-when-using-eventsystem-dot-raycastall
Cursor focusing on WorldSpace Canvas is floating above it exactly at Cursor's Surface Distance.
Cursor focusing on WorldSpace Canvas is floating above it, more that Cursor's Surface Distance.
Create a scene with WorldSpace canvas and a Raycast camera that has non-zero nearClip plane (bigger makes it more obvious). The cursor has an offset as well (set Cursor Surface Distance to be 0). The cursor will be floating above the world space canvas.
2018.3.1
2017.4.2.0
I agree with mgrman. This issue also causes the behavior I reported here. I had worked out that the nearClipPlane wasn't being taken into account but I couldn't get the values to add up quite right with what I was expecting. I didn't know about the Cursor Surface Distance, so that probably explains the discrepancy.
I believe the MRTK code did work as expected pre Unity 2017.4.3f1, and has been broken since probably due to the fix 934908.
I suspect mgrman is referring to Line 642 in FocusManager.
Changing this to:
newUiRaycastPosition.z = uiRaycastResult.distance + UIRaycastCamera.nearClipPlane;
Fixes the depth that the cursor appears at but it doesn't fix issue #3322 . This offset is probably needed in more than one place, I suspect Line 663 might be the culprit for that issue.
Most helpful comment