class MAGES::Interaction::Interactors::BaseControllerInteractor¶
Overview¶
Class for basic functionality for all controller based interactors. It handles the input from the controller and can play sounds and haptics on events. More…
class BaseControllerInteractor: public MAGES::Interaction::Interactors::BaseInteractor, public MAGES::IControllerInteractor { public: // enums enum ControllerSide; // properties ControllerSide InputControllerSide; AudioSource SoundSource; AudioClip HoverEnterSound; AudioClip HoverExitSound; AudioClip SelectEnterSound; AudioClip SelectExitSound; AudioClip ActivateEnterSound; AudioClip ActivateExitSound; float HoverEnterHapticIntensity; float HoverExitHapticIntensity; float SelectEnterHapticIntensity; float SelectExitHapticIntensity; float ActivateEnterHapticIntensity; float ActivateExitHapticIntensity; override bool IsSelectEnabled; override bool IsActivateEnabled; override float SelectionIntensity; override float ActivationIntensity; bool IsSelectInputEnabled; bool WasSelectInputEnabledThisFrame; bool WasSelectInputDisabledThisFrame; bool IsActivateInputEnabled; bool WasActivateInputEnabledThisFrame; bool WasActivateInputDisabledThisFrame; bool IsUISelectInputEnabled; bool WasUISelectInputEnabledThisFrame; bool WasUISelectInputDisabledThisFrame; // methods virtual override bool CanSelect(IInteractable interactable); bool PlayHaptics(float intensity, float duration = 0.2f); }; // direct descendants class HandInteractor;
Inherited Members¶
public: // properties IInteractionManager InteractionManager; Transform Transform; Rigidbody Rigidbody; ListColliders; UnityEvent<InteractorRegisterEventArgs> RegisterEntered; UnityEvent<InteractorDeregisterEventArgs> DeregisterEntered; UnityEvent<HoverEnterInteractionEventArgs> HoverEntered; UnityEvent<HoverExitInteractionEventArgs> HoverExited; UnityEvent<SelectEnterInteractionEventArgs> SelectEntered; UnityEvent<SelectExitInteractionEventArgs> SelectExited; UnityEvent<ActivateEnterInteractionEventArgs> ActivateEntered; UnityEvent<ActivateExitInteractionEventArgs> ActivateExited; bool IsHoverEnabled; bool HasHover; IInteractable HoveredInteractable; bool IsSelectEnabled; bool HasSelection; IInteractable SelectedInteractable; float SelectionIntensity; bool IsActivateEnabled; bool HasActivation; IInteractable ActivatedInteractable; float ActivationIntensity; IInteractionManager InteractionManager; Transform Transform; Rigidbody Rigidbody; List Colliders; UnityEvent<InteractorRegisterEventArgs> RegisterEntered; UnityEvent<InteractorDeregisterEventArgs> DeregisterEntered; UnityEvent<HoverEnterInteractionEventArgs> HoverEntered; UnityEvent<HoverExitInteractionEventArgs> HoverExited; UnityEvent<SelectEnterInteractionEventArgs> SelectEntered; UnityEvent<SelectExitInteractionEventArgs> SelectExited; UnityEvent<ActivateEnterInteractionEventArgs> ActivateEntered; UnityEvent<ActivateExitInteractionEventArgs> ActivateExited; bool IsHoverEnabled; bool HasHover; IInteractable HoveredInteractable; bool IsSelectEnabled; bool HasSelection; float SelectionIntensity; IInteractable SelectedInteractable; bool IsActivateEnabled; bool HasActivation; float ActivationIntensity; IInteractable ActivatedInteractable; AudioSource SoundSource; AudioClip HoverEnterSound; AudioClip HoverExitSound; AudioClip SelectEnterSound; AudioClip SelectExitSound; AudioClip ActivateEnterSound; AudioClip ActivateExitSound; float HoverEnterHapticIntensity; float HoverExitHapticIntensity; float SelectEnterHapticIntensity; float SelectExitHapticIntensity; float ActivateEnterHapticIntensity; float ActivateExitHapticIntensity; bool IsSelectInputEnabled; bool WasSelectInputEnabledThisFrame; bool WasSelectInputDisabledThisFrame; bool IsActivateInputEnabled; bool WasActivateInputEnabledThisFrame; bool WasActivateInputDisabledThisFrame; bool IsUISelectInputEnabled; bool WasUISelectInputEnabledThisFrame; bool WasUISelectInputDisabledThisFrame; // methods bool CanHover(IInteractable interactable); bool IsHovering(IInteractable interactable); void OnHoverEnter(HoverEnterInteractionEventArgs args); void OnHoverEntered(HoverEnterInteractionEventArgs args); void OnHoverExit(HoverExitInteractionEventArgs args); void OnHoverExited(HoverExitInteractionEventArgs args); bool CanSelect(IInteractable interactable); bool IsSelecting(IInteractable interactable); void OnSelectEnter(SelectEnterInteractionEventArgs args); void OnSelectEntered(SelectEnterInteractionEventArgs args); void OnSelectExit(SelectExitInteractionEventArgs args); void OnSelectExited(SelectExitInteractionEventArgs args); bool CanActivate(IInteractable interactable); bool IsActivating(IInteractable interactable); void OnActivateEnter(ActivateEnterInteractionEventArgs args); void OnActivateEntered(ActivateEnterInteractionEventArgs args); void OnActivateExit(ActivateExitInteractionEventArgs args); void OnActivateExited(ActivateExitInteractionEventArgs args); void OnRegisterEnter(InteractorRegisterEventArgs args); void OnRegisterEntered(InteractorRegisterEventArgs args); void OnDeregisterEnter(InteractorDeregisterEventArgs args); void OnDeregisterEntered(InteractorDeregisterEventArgs args); void GetValidTargets(List<IInteractable> result); void PreprocessInteractor(UpdatePhase updatePhase); void ProcessInteractor(UpdatePhase updatePhase); virtual bool CanHover(IInteractable interactable); virtual bool CanSelect(IInteractable interactable); virtual bool CanActivate(IInteractable interactable); virtual abstract void GetValidTargets(List<IInteractable> result) = 0; bool IsActivating(IInteractable interactable); bool IsHovering(IInteractable interactable); bool IsSelecting(IInteractable interactable); virtual void PreprocessInteractor(UpdatePhase updatePhase); virtual void ProcessInteractor(UpdatePhase updatePhase); bool PlayHaptics(float intensity, float duration);
Detailed Documentation¶
Class for basic functionality for all controller based interactors. It handles the input from the controller and can play sounds and haptics on events.
Properties¶
ControllerSide InputControllerSide
Gets or sets the controller side to bind to.
AudioSource SoundSource
Gets or sets the sound source to play sounds from.
AudioClip HoverEnterSound
Gets or sets the sound to be played when the interactor starts hovering.
AudioClip HoverExitSound
Gets or sets the sound to be played when the interactor stops hovering.
AudioClip SelectEnterSound
Gets or sets the sound to be played when the interactor starts selecting.
AudioClip SelectExitSound
Gets or sets the sound to be played when the interactor stops selecting.
AudioClip ActivateEnterSound
Gets or sets the sound to be played when the interactor starts activating.
AudioClip ActivateExitSound
Gets or sets the sound to be played when the interactor stops activating.
float HoverEnterHapticIntensity
Gets or sets the haptic feedback strength when the interactor starts hovering.
float HoverExitHapticIntensity
Gets or sets the haptic feedback strength when the interactor stops hovering.
float SelectEnterHapticIntensity
Gets or sets the haptic feedback strength when the interactor starts selecting.
float SelectExitHapticIntensity
Gets or sets the haptic feedback strength when the interactor stops selecting.
float ActivateEnterHapticIntensity
Gets or sets the haptic feedback strength when the interactor starts activating.
float ActivateExitHapticIntensity
Gets or sets the haptic feedback strength when the interactor stops activating.
override bool IsSelectEnabled
Gets a value indicating whether this interactor should send select event this frame.
Usually set by the controller input, when the grab button is pressed.
override bool IsActivateEnabled
Gets a value indicating whether this interactor should send activate event this frame.
Usually set by the controller input, when the grab button is pressed.
override float SelectionIntensity
Gets the intensity with which the controller’s selection button is pressed.
override float ActivationIntensity
Gets the intensity with which the controller’s activation button is pressed.
bool IsSelectInputEnabled
Gets a value indicating whether the controller select button is pressed.
bool WasSelectInputEnabledThisFrame
Gets a value indicating whether the controller select button was pressed this frame.
/>
bool WasSelectInputDisabledThisFrame
Gets a value indicating whether the controller select button was released this frame.
bool IsActivateInputEnabled
Gets a value indicating whether the controller activate button is pressed.
bool WasActivateInputEnabledThisFrame
Gets a value indicating whether the controller activate button was pressed this frame.
bool WasActivateInputDisabledThisFrame
Gets a value indicating whether the controller activate button was released this frame.
bool IsUISelectInputEnabled
Gets a value indicating whether the controller button that performs a UI selection is pressed.
bool WasUISelectInputEnabledThisFrame
Gets a value indicating whether the controller button that performs a UI selection was pressed this frame.
bool WasUISelectInputDisabledThisFrame
Gets a value indicating whether the controller button that performs a UI selection was released this frame.
Methods¶
virtual override bool CanSelect(IInteractable interactable)
Gets if this interactor can send select events to the interactable.
Parameters:
interactable |
The interactable to check if this interactor can send the select event to. |
Returns:
true
if the interactable can be selected by this interactor.
bool PlayHaptics(float intensity, float duration = 0.2f)
Plays haptics on the controller, if it is supported.
Parameters:
intensity |
The intensity of the haptics. |
duration |
The duration of the haptics. |
Returns:
true
if haptics are supported and the operation was successful.