XR Filter not working, how to select last interactable hit?

I’m working on a VR level creator using the Unity XR Interaction Toolkit and have implemented move, rotate, and scale tools using the XR Simple Interactable for selection. But I have one change that I can’t figure out how to make.

Basically when the tools are behind other interactables, I’d like to have them still be selectable and take priority over the other interactables, but I can’t find a way to do this by googling and looking at different settings.

Edit: I found out there’s a thing called an XR Filter but when applying it I can’t select anything at all?


I fixed the issue by making a custom ray interactor script.

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;

public class BuilderRayInteractor : XRRayInteractor
{
    public override void GetValidTargets(List<IXRInteractable> targets)
    {
        base.GetValidTargets(targets);

        targets.Sort((a, b) =>
        {
            bool isATool = a.transform.CompareTag("Tool");
            bool isBTool = b.transform.CompareTag("Tool"); 

            if (isATool && !isBTool) return -1;
            if (!isATool && isBTool) return 1; 
            return 0;
        });

    }
}