- Home /
Question by
Jeffruddick · Apr 03, 2020 at 12:25 PM ·
uiiosaugmented reality
XR Interaction Toolkit
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?
Comment
Answer by PincerGame · Dec 07, 2020 at 09:51 AM
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
}
}
Answer by Boudewijn · Jun 25, 2020 at 08:16 AM
Have you attached the 'Tracked Device Graphic Raycaster' script?