Search Unity

Bug: UI's "raycast target" property ignored.

Discussion in 'AR/VR (XR) Discussion' started by snw, Mar 14, 2020.

  1. snw

    snw

    Joined:
    Mar 13, 2014
    Posts:
    42
    Hi,

    while working with the XR Interaction Toolkit, I encountered the following behaviour:
    UI elements, that have their "raycast target" property disabled, still get detected by the TrackedDeviceGraphicRaycaster. This results in UI elements catching rays even if they shouldn't.

    This bug has already been reported:
    Issue ID: 1221300

    Link: https://issuetracker.unity3d.com/is...react-to-ui-when-raycast-target-is-turned-off

    Specs:
    Unity 2019.3.5f1
    XRI Toolkit 0.9.3

    Can we expect the bug to be fixed soon, i.e. in the next package update?


    Cheers
     
  2. snw

    snw

    Joined:
    Mar 13, 2014
    Posts:
    42
    I'm using this workaround for now:

    In TrackedDeviceGraphicRaycaster.cs, I added a check for the "raycast target" property to the SortedRaycastGraphics method (see line 7).

    Code (CSharp):
    1. private void SortedRaycastGraphics(Canvas canvas, Ray ray, float maxDistance, LayerMask layerMask, List<RaycastHitData> results){
    2.     var graphics = GraphicRegistry.GetGraphicsForCanvas(canvas);
    3.     s_SortedGraphics.Clear();
    4.     for (int i = 0; i < graphics.Count; ++i){
    5.         Graphic graphic = graphics[i];
    6.        
    7.         if (!graphic.raycastTarget) continue;
    8. ...

    Looking forward to the proper fix ;)


    Cheers
     
    Last edited: Mar 15, 2020
    LorenzoValente and JoeStrout like this.
  3. snw

    snw

    Joined:
    Mar 13, 2014
    Posts:
    42
  4. lazylukey

    lazylukey

    Joined:
    May 26, 2017
    Posts:
    36
    I've just found this is also a bug in the new Input System (v1.3.0) TrackedDeviceRaycaster component. Is this just an oversight?