Class XRInteractorAffordanceStateProvider
State Machine component that derives an interaction affordance state from an associated IXRInteractor.
Inheritance
Inherited Members
Namespace: UnityEngine.XR.Interaction.Toolkit.AffordanceSystem.State
Syntax
[AddComponentMenu("Affordance System/XR Interactor Affordance State Provider", 11)]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.xr.interaction.toolkit@2.4/api/UnityEngine.XR.Interaction.Toolkit.AffordanceSystem.State.XRInteractorAffordanceStateProvider.html")]
[DisallowMultipleComponent]
public class XRInteractorAffordanceStateProvider : BaseAffordanceStateProvider
Properties
activateClickAnimationMode
Condition to trigger click animation for activated interaction events.
Declaration
public XRInteractorAffordanceStateProvider.ActivateClickAnimationMode activateClickAnimationMode { get; set; }
Property Value
Type | Description |
---|---|
XRInteractorAffordanceStateProvider.ActivateClickAnimationMode |
clickAnimationCurve
Animation curve reference for click animation events.
Declaration
public AnimationCurveDatumProperty clickAnimationCurve { get; set; }
Property Value
Type | Description |
---|---|
AnimationCurveDatumProperty |
clickAnimationDuration
Duration of click animations for selected and activated events.
Declaration
public float clickAnimationDuration { get; set; }
Property Value
Type | Description |
---|---|
Single |
hasUIHover
Is the interactor overlapping a UI Canvas and hitting a UI raycast target.
Declaration
protected virtual bool hasUIHover { get; }
Property Value
Type | Description |
---|---|
Boolean |
hasUISelection
Whether the interactor is hovering UI and the interactor select action is pressed.
Declaration
protected virtual bool hasUISelection { get; }
Property Value
Type | Description |
---|---|
Boolean |
hasXRHover
Is attached interactor in a hovered state.
Declaration
protected virtual bool hasXRHover { get; }
Property Value
Type | Description |
---|---|
Boolean |
hasXRSelection
Is attached interactor in a selected state.
Declaration
protected virtual bool hasXRSelection { get; }
Property Value
Type | Description |
---|---|
Boolean |
ignoreActivateEvents
When activate events are registered and this is true, the state will fallback to idle or disabled.
Declaration
public bool ignoreActivateEvents { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
ignoreHoverEvents
When hover events are registered and this is true, the state will fallback to idle or disabled.
Declaration
public bool ignoreHoverEvents { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
ignoreSelectEvents
When select events are registered and this is true, the state will fallback to idle or disabled.
Declaration
public bool ignoreSelectEvents { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
ignoreUGUIHover
With the XR Ray Interactor it is possible to trigger select events from the ray interactor overlapping with a canvas.
Declaration
public bool ignoreUGUIHover { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
ignoreUGUISelect
With the XR Ray Interactor it is possible to trigger select events from the ray interactor overlapping with a canvas and triggering the select input.
Declaration
public bool ignoreUGUISelect { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
ignoreXRInteractionEvents
This option will prevent Hover, Select, and Activate events from being triggered when they come from the XR Interaction Manager. UGUI hover and select events will still come through.
Declaration
public bool ignoreXRInteractionEvents { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
interactorSource
The interactor component that drives the affordance states. If null, Unity will try and find an interactor component attached.
Declaration
public Object interactorSource { get; set; }
Property Value
Type | Description |
---|---|
Object |
isActivated
Is attached interactable in an activated state.
Declaration
protected virtual bool isActivated { get; }
Property Value
Type | Description |
---|---|
Boolean |
isBlockedByGroup
Declaration
protected virtual bool isBlockedByGroup { get; }
Property Value
Type | Description |
---|---|
Boolean |
isRegistered
Is attached interactor in a registered state.
Declaration
protected virtual bool isRegistered { get; }
Property Value
Type | Description |
---|---|
Boolean |
selectClickAnimationMode
Condition to trigger click animation for Selected interaction events.
Declaration
public XRInteractorAffordanceStateProvider.SelectClickAnimationMode selectClickAnimationMode { get; set; }
Property Value
Type | Description |
---|---|
XRInteractorAffordanceStateProvider.SelectClickAnimationMode |
Methods
ActivatedClickBehavior()
Handles starting the activated click animation coroutine. Stops any previously started coroutine.
Declaration
protected virtual void ActivatedClickBehavior()
Awake()
See MonoBehaviour.
Declaration
protected void Awake()
BindToProviders()
Inform all registered receivers of the current affordance state data and subscribe to changes of the affordance state.
Declaration
protected override void BindToProviders()
Overrides
Remarks
This method is automatically called by Unity when this component is enabled.
See Also
ClearBindings()
Triggers unbind action on all bindings and destroys all stored binding actions, as well as clears the group of all registered bindings.
Declaration
protected override void ClearBindings()
Overrides
Remarks
This method is automatically called by Unity when this component is disabled.
ClickAnimation(Byte, Single, Action)
Click animation coroutine that plays over a set period of time, transitioning between the lower and upper bounds of a given affordance state.
Declaration
protected virtual IEnumerator ClickAnimation(byte targetStateIndex, float duration, Action onComplete = null)
Parameters
Type | Name | Description |
---|---|---|
Byte | targetStateIndex | Target animation state with bounds which to transition between. |
Single | duration | Duration of the animation. |
Action | onComplete | OnComplete callback action. |
Returns
Type | Description |
---|---|
IEnumerator | Enumerator used to play as a coroutine. |
GenerateNewAffordanceState()
Evaluates the state of the current interactor to generate a corresponding AffordanceStateData.
Declaration
protected virtual AffordanceStateData GenerateNewAffordanceState()
Returns
Type | Description |
---|---|
AffordanceStateData | Newly generated affordance state corresponding to the interactor state. |
OnHoverEntered(HoverEnterEventArgs)
Callback triggered by IXRHoverInteractor when this interactor begins hovering. Refreshes the affordance state.
Declaration
protected virtual void OnHoverEntered(HoverEnterEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
HoverEnterEventArgs | args | HoverEnterEventArgs callback args. |
See Also
OnHoverExited(HoverExitEventArgs)
Callback triggered by IXRHoverInteractor when this interactor is no longer hovering. Refreshes the affordance state.
Declaration
protected virtual void OnHoverExited(HoverExitEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
HoverExitEventArgs | args | HoverExitEventArgs callback args. |
See Also
OnLargestInteractionStrengthChanged(Single)
Callback triggered by IXRInteractionStrengthInteractor when the largest interaction strength of this interactor changes. Refreshes the affordance state.
Declaration
protected virtual void OnLargestInteractionStrengthChanged(float value)
Parameters
Type | Name | Description |
---|---|---|
Single | value | The new largest interaction strength value of this interactor. |
OnRegistered(InteractorRegisteredEventArgs)
Callback triggered when the interactor is registered with the XRInteractionManager. Sets the internal isRegistered flag to true and refreshes the affordance state.
Declaration
protected virtual void OnRegistered(InteractorRegisteredEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
InteractorRegisteredEventArgs | args | InteractorRegisteredEventArgs callback args. |
OnSelectEntered(SelectEnterEventArgs)
Callback triggered by IXRSelectInteractor when the first interactor begins selecting. Refreshes the affordance state.
Declaration
protected virtual void OnSelectEntered(SelectEnterEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
SelectEnterEventArgs | args | SelectEnterEventArgs callback args. |
See Also
OnSelectExited(SelectExitEventArgs)
Callback triggered by IXRSelectInteractor when this interactor is no longer selecting. Refreshes the affordance state.
Declaration
protected virtual void OnSelectExited(SelectExitEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
SelectExitEventArgs | args | SelectExitEventArgs callback args. |
See Also
OnUnregistered(InteractorUnregisteredEventArgs)
Callback triggered when the interactor is unregistered with the XRInteractionManager. Sets the internal isRegistered flag to false and refreshes the affordance state.
Declaration
protected virtual void OnUnregistered(InteractorUnregisteredEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
InteractorUnregisteredEventArgs | args | InteractorUnregisteredEventArgs callback args. |
RefreshState()
Re-evaluates the current affordance state and triggers events for receivers if it changed.
Declaration
public void RefreshState()
SelectedClickBehavior()
Handles starting the selected click animation coroutine. Stops any previously started coroutine.
Declaration
protected virtual void SelectedClickBehavior()
SetBoundInteractionReceiver(IXRInteractor)
Bind affordance provider state to IXRInteractor state and events.
Declaration
public bool SetBoundInteractionReceiver(IXRInteractor interactor)
Parameters
Type | Name | Description |
---|---|---|
IXRInteractor | interactor | Receiver to bind events from. |
Returns
Type | Description |
---|---|
Boolean | Whether binding was successful. |