docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class XRDistanceEvaluator

    Evaluates the Interactor distance from the target Interactable. Targets close to the Interactor will receive a highest score and targets far way will receive a lower score.

    Inheritance
    object
    XRTargetEvaluator
    XRDistanceEvaluator
    Implements
    IDisposable
    Inherited Members
    XRTargetEvaluator.filter
    XRTargetEvaluator.enabled
    XRTargetEvaluator.weight
    XRTargetEvaluator.disposed
    XRTargetEvaluator.Awake()
    XRTargetEvaluator.OnDispose()
    XRTargetEvaluator.OnEnable()
    XRTargetEvaluator.OnDisable()
    XRTargetEvaluator.GetWeightedScore(IXRInteractor, IXRInteractable)
    XRTargetEvaluator.Dispose()
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.XR.Interaction.Toolkit.Filtering
    Assembly: Unity.XR.Interaction.Toolkit.dll
    Syntax
    [Serializable]
    public class XRDistanceEvaluator : XRTargetEvaluator, IDisposable

    Properties

    maxDistance

    The maximum distance from the Interactor. Any target from this distance will receive a 0 normalized score.

    Declaration
    public float maxDistance { get; set; }
    Property Value
    Type Description
    float

    Methods

    CalculateNormalizedScore(IXRInteractor, IXRInteractable)

    Calculates and returns a normalized value that represents the intention to select the given target Interactable.
    The highest score of 1 represents the intention to select the given target and the lowest score of 0 the intention to not select it, any value in between is valid.

    Declaration
    protected override float CalculateNormalizedScore(IXRInteractor interactor, IXRInteractable target)
    Parameters
    Type Name Description
    IXRInteractor interactor

    The Interactor whose Interactable targets (candidates) are being evaluated.

    IXRInteractable target

    The target Interactable to evaluate the normalized score.

    Returns
    Type Description
    float

    Returns the normalized interaction score of the given target.
    It's a good practice to return a value between 0 and 1 inclusive and edit the weight curve to evaluate the target weighted interaction score.

    Overrides
    XRTargetEvaluator.CalculateNormalizedScore(IXRInteractor, IXRInteractable)
    Remarks

    The returned normalized score is evaluated by the weight curve (in GetWeightedScore(IXRInteractor, IXRInteractable)) and then (in Process(IXRInteractor, List<IXRInteractable>, List<IXRInteractable>)) it's multiplied by the other evaluator weighted score in the same filter to get the target final score.
    You cannot disable, remove, or dispose evaluators from the filter in this method. You also cannot unlink Interactors from the filter in this method.

    See Also
    XRTargetFilter
    GetValidTargets(List<IXRInteractable>)

    Reset()

    (Editor Only) Unity calls this automatically when adding the evaluator to the Filter Target the first time. This function is only called in the Unity editor. Reset is most commonly used to give good default values in the Inspector.

    Declaration
    public override void Reset()
    Overrides
    XRTargetEvaluator.Reset()

    Implements

    IDisposable
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)