I’m using a UI canvas with the XR Interaction toolkit and my UI button raycasts are passing through the canvas onto the game objects. I found a dozen or so fixes and I can’t seem to get one to work with the XR Interaction toolkit and iOS. Any ideas?
Have you attached the ‘Tracked Device Graphic Raycaster’ script?
Hi, can you try this one out. It works for me.
bool RayHitUI()
{
//Create the PointerEventData with null for the EventSystem
PointerEventData ped = new PointerEventData(null);
//Set required parameters, in this case, mouse position
ped.position = Input.mousePosition;
//Create list to receive all results
List<RaycastResult> results = new List<RaycastResult>();
//Raycast it
graphicRaycaster.Raycast(ped, results);
if (results.Count > 0)
{
return results.Any(r => r.gameObject.layer == LAYER_UI);
}
return false;
}
void update(){
if( RayHitUI() ){
//Ignore the cast
}
}