Reason
When XRUIInputModule
processes XRInput in DoProcess
, it needs to obtain the camera screen position, and this camera is not the one on the Canvas, but Camera.main
, which can be viewed in its parent class UIInputModule
’s property uiCamera
.
The method ProcessTrackedDevice
of UIInputModule
will call TryGetCamera
, and if uiCamera
cannot be found at that time, it will not execute and will not report an error.
Code snippet:
internal void ProcessTrackedDevice(ref TrackedDeviceModel deviceState, bool force = false)
{
...
if (TryGetCamera(eventData, out var screenPointCamera)) {...}
//no else
deviceState.OnFrameFinished();
}
If Camera.main
is not null, but the transform of Camera.main
is different from the canvas.worldCamera
on the Canvas, it will cause a shift in the click position.
So the worldCamera
of Canvas needs to be Camera.main
.
If you encounter click offset or are unable to exit the UI controls normally, you can check the settings mentioned above
Suggestions
It’s all very normal, but when I wanted to rewrite the DoProcess()
method of XRUIInputModule
, I found that the access modifier of the readonly List<RegisteredInteractor> m_RegisteredInteractors
it depends on is private, and its corresponding generic type is also private, which prevents me from accessing all the UIInteractors
I hope it can be changed to protected or internal later
Otherwise, I cannot choose the uiCamera based on the information from the interactor
Currently, I am solving it through partial
Others
I am not good at English, please understand