My current problem is that the cursor appears too far away from a button. You can see in the screenshot what I mean. Hovering over a button from the list lookes like this:
Question: What can I do so the cursor get closer to the button, because on the HoloLens you see the distance?
Looking somewhere else on the canvas except the buttons, the cursor gets closer:
--Edit--
I should mention that the scene has a scaled cube (the gray thing in the screenshot) and in front of that a world canvas (white thing), which contains the scrollview/list.
I saw the same behaviour for UI elements.
I can only provide you a workaround. It is a bit hacky but it works:
Go through all UI elements especially Text
and Image
and disable the option RayCast Target
.
This makes the Cursor be sitting right on top of them ... but you will notice your Button
s are now non-responsive and you can not interact with them anymore.
This happens because the Physics system requires either a RayCastTarget or a Collider
in order to fire it's pointer events like e.g. PointerEnter
, PointerDown
etc.
Therefore now add a BoxCollider
(not BoxCollider2D
!) to your Button
s and scale it to the correct size. It looks like you are using a VerticalLayoutGroup
so you can simply correct the positioning of the BoxCollider
by setting the RectTransform
to centered once (the VerticalLayoutgroup
will anyway re-enforce the Top-Left anchoring). In my case the BoxCollider
needs with 0.8
and height 0.1
... and for the z
I choose 0.01
but it can be smaller if you whish
Hurray, now the buttons are interactable again and the Cursor only has it's usual distance + the half of the choosen z
thikness of the BoxColliders
.
Since the Background cube has it's own BoxCollider
anyway we don't need to add further Colliders
for the ScrollView
and UI panels.
You might have to add some though for the ScrollBars as well if you need them!
As said this is more like a quick workaround and might not be a final solution since whenever a size of the Button
or the ScrollRect
is changed you have to rework those hardcoded BoxCollider
dimesnions as well ...