docs.unity3d.com
    Show / Hide Table of Contents

    Interface IXRTargetFilter

    An interface responsible to filter a list of Interactable targets (candidates) for interaction with a linked Interactor.

    Namespace: UnityEngine.XR.Interaction.Toolkit.Filtering
    Syntax
    public interface IXRTargetFilter
    Remarks

    An Interactor and an implementation of this interface are linked when a call to Link(IXRInteractor) happens and they are unlinked when a call to Unlink(IXRInteractor) happens. A linked Interactor can forward its Interactable target filtering logic to this interface implementation by calling Process(IXRInteractor, List<IXRInteractable>, List<IXRInteractable>).
    An XRBaseInteractor and a Target Filter can be linked when an implementation of this interface is assigned to targetFilter.
    It's possible to have multiple Interactors linked to the same Target Filter.

    Properties

    canProcess

    Whether this Target Filter can process and filter targets. Filters that can process targets receive calls to Process(IXRInteractor, List<IXRInteractable>, List<IXRInteractable>), filters that cannot process do not.

    Declaration
    bool canProcess { get; }
    Property Value
    Type Description
    Boolean

    Methods

    Link(IXRInteractor)

    Called by Unity when the given Interactor links to this filter. Use this to do any code initialization for the given Interactor.

    Declaration
    void Link(IXRInteractor interactor)
    Parameters
    Type Name Description
    IXRInteractor interactor

    The Interactor being linked to this filter.

    Process(IXRInteractor, List<IXRInteractable>, List<IXRInteractable>)

    Called by the linked Interactor to filter the Interactables that it could possibly interact with this frame. Implement your custom logic to filter the Interactable candidates in this method.

    Declaration
    void Process(IXRInteractor interactor, List<IXRInteractable> targets, List<IXRInteractable> results)
    Parameters
    Type Name Description
    IXRInteractor interactor

    The linked Interactor whose Interactable candidates (or targets) are being filtered.

    List<IXRInteractable> targets

    The read only list of candidate Interactables to filter. This list should not be modified.

    List<IXRInteractable> results

    The results list to populate with the filtered results. This list should be sorted by priority (with highest priority first).

    Remarks

    It's recommended to call this from an implementation of GetValidTargets(List<IXRInteractable>).

    Unlink(IXRInteractor)

    Called by Unity when the given Interactor unlinks from this filter. Use this to do any code cleanup for the given Interactor.

    Declaration
    void Unlink(IXRInteractor interactor)
    Parameters
    Type Name Description
    IXRInteractor interactor

    The Interactor being unlinked from this filter.

    See Also

    XRBaseTargetFilter
    XRTargetFilter
    GetValidTargets(List<IXRInteractable>)
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023