Mixedrealitytoolkit-unity: FocusManager does not compute distance to Canvas correctly

Created on 21 Jan 2019  路  7Comments  路  Source: microsoft/MixedRealityToolkit-Unity

Overview

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

Expected Behavior

Cursor focusing on WorldSpace Canvas is floating above it exactly at Cursor's Surface Distance.

Actual Behavior

Cursor focusing on WorldSpace Canvas is floating above it, more that Cursor's Surface Distance.

Steps to reproduce

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.

Unity Editor Version

2018.3.1

Mixed Reality Toolkit Release Version

2017.4.2.0

Bug

Most helpful comment

All 7 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chrisfromwork picture chrisfromwork  路  3Comments

reillydonovan picture reillydonovan  路  3Comments

nrchuanqi picture nrchuanqi  路  3Comments

overedge picture overedge  路  3Comments

DanAndersen picture DanAndersen  路  3Comments