Class XRInteractableAffordanceStateProvider
State Machine component that derives an interaction affordance state from an associated IXRInteractable.
Inheritance
Inherited Members
Namespace: UnityEngine .XR.Interaction.Toolkit.AffordanceSystem .State
Assembly: Unity.XR.Interaction.Toolkit.dll
Syntax
[AddComponentMenu("Affordance System/XR Interactable Affordance State Provider", 11)]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.xr.interaction.toolkit@2.6/api/UnityEngine.XR.Interaction.Toolkit.AffordanceSystem.State.XRInteractableAffordanceStateProvider.html")]
[DisallowMultipleComponent]
public class XRInteractableAffordanceStateProvider : BaseAffordanceStateProvider
Properties
activateClickAnimationMode
Condition to trigger click animation for activated interaction events.
Declaration
public XRInteractableAffordanceStateProvider.ActivateClickAnimationMode activateClickAnimationMode { get; set; }
Property Value
Type | Description |
---|---|
XRInteractable |
See Also
clickAnimationCurve
Animation curve reference for click animation events.
Declaration
public AnimationCurveDatumProperty clickAnimationCurve { get; set; }
Property Value
Type | Description |
---|---|
Animation |
clickAnimationDuration
Duration of click animations for selected and activated events.
Declaration
public float clickAnimationDuration { get; set; }
Property Value
Type | Description |
---|---|
float |
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 |
---|---|
bool |
ignoreFocusEvents
When focus events are registered and this is true, the state will fallback to idle or disabled.
Declaration
public bool ignoreFocusEvents { get; set; }
Property Value
Type | Description |
---|---|
bool |
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 |
---|---|
bool |
ignoreHoverPriorityEvents
When hover events are registered and this is true, the state will fallback to hover. When this is false, this provider will check if the Interactable Source has priority for selection when hovered, and update its state accordingly.
Declaration
public bool ignoreHoverPriorityEvents { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
When updating this value to false during runtime, previously hover events are ignored.
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 |
---|---|
bool |
interactableSource
The interactable component that drives the affordance states. If null, Unity will try and find an interactable component attached.
Declaration
public Object interactableSource { 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 |
---|---|
bool |
isFocused
Is attached interactable in a focused state.
Declaration
protected virtual bool isFocused { get; }
Property Value
Type | Description |
---|---|
bool |
isHovered
Is attached interactable in a hovered state.
Declaration
protected virtual bool isHovered { get; }
Property Value
Type | Description |
---|---|
bool |
isRegistered
Is attached interactable in a registered state.
Declaration
protected virtual bool isRegistered { get; }
Property Value
Type | Description |
---|---|
bool |
isSelected
Is attached interactable in a selected state.
Declaration
protected virtual bool isSelected { get; }
Property Value
Type | Description |
---|---|
bool |
selectClickAnimationMode
Condition to trigger click animation for Selected interaction events.
Declaration
public XRInteractableAffordanceStateProvider.SelectClickAnimationMode selectClickAnimationMode { get; set; }
Property Value
Type | Description |
---|---|
XRInteractable |
See Also
Methods
ActivatedClickBehavior()
Handles starting the activated click animation coroutine. Stops any previously started coroutine.
Declaration
protected virtual void ActivatedClickBehavior()
Awake()
See Mono
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, float, 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. |
float | 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 interactable to generate a corresponding Affordance
Declaration
protected virtual AffordanceStateData GenerateNewAffordanceState()
Returns
Type | Description |
---|---|
Affordance |
Newly generated affordance state corresponding to the interactable state. |
OnActivatedEvent(ActivateEventArgs)
Callback triggered by IXRActivate
Declaration
protected virtual void OnActivatedEvent(ActivateEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Activate |
args | Activate |
See Also
OnDeactivatedEvent(DeactivateEventArgs)
Callback triggered by IXRActivate
Declaration
protected virtual void OnDeactivatedEvent(DeactivateEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Deactivate |
args | Deactivate |
See Also
OnFirstFocusEntered(FocusEnterEventArgs)
Callback triggered by IXRFocus
Declaration
protected virtual void OnFirstFocusEntered(FocusEnterEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Focus |
args | Focus |
See Also
OnFirstHoverEntered(HoverEnterEventArgs)
Callback triggered by IXRHover
Declaration
protected virtual void OnFirstHoverEntered(HoverEnterEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Hover |
args | Hover |
See Also
OnFirstSelectEntered(SelectEnterEventArgs)
Callback triggered by IXRSelect
Declaration
protected virtual void OnFirstSelectEntered(SelectEnterEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Select |
args | Select |
See Also
OnHoverEntered(HoverEnterEventArgs)
Callback triggered by IXRHover
Declaration
protected virtual void OnHoverEntered(HoverEnterEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Hover |
args | Hover |
See Also
OnHoverExited(HoverExitEventArgs)
Callback triggered by IXRHover
Declaration
protected virtual void OnHoverExited(HoverExitEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Hover |
args | Hover |
See Also
OnLargestInteractionStrengthChanged(float)
Callback triggered by IXRInteraction
Declaration
protected virtual void OnLargestInteractionStrengthChanged(float value)
Parameters
Type | Name | Description |
---|---|---|
float | value | The new largest interaction strength value of all interactors hovering or selecting the interactable. |
OnLastFocusExited(FocusExitEventArgs)
Callback triggered by IXRFocus
Declaration
protected virtual void OnLastFocusExited(FocusExitEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Focus |
args | Focus |
See Also
OnLastHoverExited(HoverExitEventArgs)
Callback triggered by IXRHover
Declaration
protected virtual void OnLastHoverExited(HoverExitEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Hover |
args | Hover |
See Also
OnLastSelectExited(SelectExitEventArgs)
Callback triggered by IXRSelect
Declaration
protected virtual void OnLastSelectExited(SelectExitEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Select |
args | Select |
See Also
OnRegistered(InteractableRegisteredEventArgs)
Callback triggered when the interactable is registered with the XRInteraction
Declaration
protected virtual void OnRegistered(InteractableRegisteredEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Interactable |
args | Interactable |
OnUnregistered(InteractableUnregisteredEventArgs)
Callback triggered when the interactable is unregistered with the XRInteraction
Declaration
protected virtual void OnUnregistered(InteractableUnregisteredEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
Interactable |
args | Interactable |
OnValidate()
See Mono
Declaration
protected override void OnValidate()
Overrides
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(IXRInteractable)
Bind affordance provider state to IXRInteractable state and events.
Declaration
public bool SetBoundInteractionReceiver(IXRInteractable receiver)
Parameters
Type | Name | Description |
---|---|---|
IXRInteractable | receiver | Receiver to bind events from. |
Returns
Type | Description |
---|---|
bool | Whether binding was successful. |