API reference
API reference
Select your platform
No SDKs available
No versions available

Interactor Class

Extends MonoBehaviour, IInteractor
Base class for most concrete interactor types.
New interactors can be created by inheriting from this class directly; however, it is also common for new interactors to inherit from PointerInteractor<TInteractor, TInteractable>, a descendent type which adds features for characterizing interactions as PointerEvents.
Interactions can be wholly defined by three things: the concrete Interactor, the concrete Interactable, and the logic governing their coordination. Subclasses are responsible for implementing that coordination logic via template methods that operate on the concrete interactor and interactable classes.
This type has a curiously recurring generic argument TInteractor , which should be the concrete interactor type which derives from this type and is uniquely associated with TInteractable .

Protected Fields

ulong _nativeId[Get]
TInteractable _candidate[Get]
TInteractable _interactable[Get]
TInteractable _selectedInteractable[Get]
bool _started[Get]

Properties

Implementation of IInteractor.ShouldHover; for details, please refer to the related documentation provided for that interface.
Implementation of IInteractor.ShouldUnhover; for details, please refer to the related documentation provided for that interface.
Implementation of IInteractor.ShouldSelect; for details, please refer to the related documentation provided for that interface.
Implementation of IInteractor.ShouldUnselect; for details, please refer to the related documentation provided for that interface.
This is an internal API which sets or retrieves the maximum number of times the interactor group will execute its processing loop (assessing and enacting changes in the groups InteractorState, among other effects) within a single frame.
The implications of this are complex, and depending on or modifying this value is not recommended.
ISelector Selector[Get]
Implementation of IInteractorView.State; for details, please refer to the related documentation provided for that interface.
Implementation of IInteractorView.CandidateProperties; for details, please refer to the related documentation provided for that interface.
Implementation of IInteractorView.Data; for details, please refer to the related documentation provided for that interface.
Implementation of IUpdateDriver.IsRootDriver; for details, please refer to the related documentation provided for that interface.

Events

Implementation of IInteractorView.WhenStateChanged; for details, please refer to the related documentation provided for that interface.
Implementation of IInteractorView.WhenPreprocessed; for details, please refer to the related documentation provided for that interface.
Implementation of IInteractorView.WhenProcessed; for details, please refer to the related documentation provided for that interface.
Implementation of IInteractorView.WhenPostprocessed; for details, please refer to the related documentation provided for that interface.

Fields

The current interaction candidate.
This is the TInteractable with which this interactor can, but may not yet have begun to, interact. The candidate is primarily used by the interactor itself (as the thing it knows it can interact with next) and by containing interactor groups, which frequently use the availability or unavailability of a candidate in a given frame to assess which interactors should perform the interactions of which they're capable.
The TInteractable with which this interactor is currently interacting.
This may or may not be the same as the Candidate
The TInteractable which this interactor is currently selecting.
This must be the same as Interactable, and neither SelectedInteractable nor Interactable will change value until this interactor unselects.
Implementation of IInteractorView.HasCandidate; for details, please refer to the related documentation provided for that interface.
Implementation of IInteractorView.HasInteractable; for details, please refer to the related documentation provided for that interface.
Implementation of IInteractorView.HasSelectedInteractable; for details, please refer to the related documentation provided for that interface.
An event indicating that a new value is available via Interactable.
In terms of InteractorState, this occurs when the interactor begins hovering a new interactable.
An event indicating that Interactable will now return null.
In terms of InteractorState, this occurs when the interactor ceases hovering an interactable.
An event indicating that a new value is available via SelectedInteractable.
In terms of InteractorState, this occurs when the interactor begins selecting a new interactable.
An event indicating that SelectedInteractable will now return null.
In terms of InteractorState, this occurs when the interactor ceases selecting an interactable.
Implementation of IInteractorView.Identifier; for details, please refer to the related documentation provided for that interface.

Protected Functions

virtual void DoPreprocess ( )
virtual void DoNormalUpdate ( )
virtual void DoHoverUpdate ( )
virtual void DoSelectUpdate ( )
virtual void DoPostprocess ( )
virtual bool ComputeShouldSelect ( )
virtual bool ComputeShouldUnselect ( )
virtual void InteractableSet
( TInteractable interactable )
virtual void InteractableUnset
( TInteractable interactable )
virtual void InteractableSelected
( TInteractable interactable )
virtual void InteractableUnselected
( TInteractable interactable )
virtual void Awake ( )
virtual void Start ( )
virtual void OnEnable ( )
virtual void OnDisable ( )
virtual void OnDestroy ( )
abstract TInteractable ComputeCandidate ( )
virtual int ComputeCandidateTiebreaker
( TInteractable a,
TInteractable b )
virtual void HandleEnabled ( )
virtual void HandleDisabled ( )
virtual void HandleSelected ( )
virtual void HandleUnselected ( )
virtual void Update ( )

Member Functions

Overrides the interactor's ComputeCandidate method with a new method.
ComputeCandidate is part of the core processing flow of IInteractors and is the primary way that individual interactors decide what they want to interact with. Computing a new candidate does not actually do the interaction because not all interaction candidates will result in interactions: an InteractorGroup might decide that one interactor's candidate cannot be acted upon because another interactor in the group is already interacting, for example. Managing this nuance, and the state associated with it, is why direct calls to methods like IInteractor.Hover cannot safely be used to force an interactor into a desired state, as attempting to do so violates the interactor's processing flow and may cause it to have invalid internal state. SetComputeCandidateOverride, however, can serve a similar function by arbitrarily controlling candidate discovery in the interactor. In this way, while an interactor still cannot be generally forced to interact with a specific candidate, it can be forced to consider a specific candidate within its proper processing flow, which unless prevented (by an intervening InteractorGroup, for example) can be made to result in the desired interaction.
Parameters
computeCandidate
The method used instead of the interactable's existing ComputeCandidate() method.
shouldClearOverrideOnSelect
If true, clear the computeCandidate function once you select an interactable.
Clears the function provided in SetComputeCandidateOverride.
This is called when the interactor force releases an interactable.
Overrides the interactor's ComputeShouldSelect() method with a new method.
For similar reasons to those discussed in the documentation for SetComputeCandidateOverride(Func<TInteractable>, bool), an interactor cannot be directly forced to select an interactable (except in special, bespoke methods such as HandGrab.HandGrabInteractor.ForceSelect(HandGrab.HandGrabInteractable, bool)), but the logic it uses to decide whether or not to select can be overriden so that its normal processing is guaranteed to result in selection (again, absent intervening forces such as an InteractorGroup).
Parameters
computeShouldSelect
The method used instead of the interactor's existing ComputeShouldSelect() method.
clearOverrideOnSelect
If true, clear the computeShouldSelect function once you select an interactable.
Clears the function provided in SetComputeShouldSelectOverride.
This is called when the interactor force releases an interactable.
Overrides the interactor's ComputeShouldUnselect method with a new method.
See SetComputeShouldSelectOverride(Func<bool>, bool) for relevant details
Parameters
computeShouldUnselect
The method used instead of the interactor's existing ComputeShouldUnselect() method.
clearOverrideOnUnselect
If true, clear the computeShouldUnselect function once you unselect an interactable.
Clears the function provided in SetComputeShouldUnselectOverride.
This is called when the interactor unselects an interactable.
Implementation of IInteractor.Preprocess; executes any logic that should run before the interactor-specific logic.
Runs before Process and Postprocess. This method should never be invoked directly except by either this interactor instance itself or the InteractorGroup to which it belongs.
Implementation of IInteractor.Process; runs interactor-specific logic based on the interactor's current state.
Runs after Preprocess but before Postprocess. Can be called multiple times per interaction frame, with the number capped by the value of MaxIterationsPerFrame. This method should never be invoked directly except by either this interactor instance itself or the InteractorGroup to which it belongs.
Implementation of IInteractor.Process; executes any logic that should run after the interactor-specific logic.
Runs after both Preprocess and Process. This method should never be invoked directly except by either this interactor instance itself or the InteractorGroup to which it belongs.
Implementation of IInteractor.ProcessCandidate; for details, please refer to the related documentation provided for that interface.
Causes the interactor to unselect or unhover an interactable.
Called when an interactable is currently selected or hovered but a PointerEvent of type PointerEventType.Cancel occurs.
Implementation of IInteractor.Hover; for details, please refer to the related documentation provided for that interface.
Implementation of IInteractor.Unhover; for details, please refer to the related documentation provided for that interface.
Implementation of IInteractor.Select; for details, please refer to the related documentation provided for that interface.
Implementation of IInteractor.Unselect; for details, please refer to the related documentation provided for that interface.
Determines if this interactor can interact with an interactable.
Despite its name, this method is not a part of the interactor processing flow alongside ShouldSelect and Select; both of those refer to things that respectively should and do happen now, as part of processing. CanSelect does not specifically test whether or not an interactable can be selected right now; for example, a grab interactor can only select interactables that are spatially nearby, but proximity is not taken into account at all by CanSelect. Rather, CanSelect assesses whether an interactable can be selected more generally, such as whether there are any special rules which should prevent the selection even if every other condition were satisfied. InteractableFilters are the primary form such selection-blocking rules take, but descendent classes can introduce any other type of selection blocker they wish by overriding CanSelect.
Parameters
interactable
The interactable to check against.
Returns
True if the interactor can interact with the given interactable.
Implementation of IInteractor.Enable; for details, please refer to the related documentation provided for that interface.
Implementation of IInteractor.Disable; for details, please refer to the related documentation provided for that interface.
Implementation of IUpdateDriver.Drive.
This method should never be invoked directly by anything other than this instance (when IsRootDriver is true) or the IUpdateDriver serving the role of root driver. This method encapsulates the entire processing flow of the interactor, invoking many of the core methods from IInteractor (Enable, Process, etc.) in the correct order and with the appropriate state management. Modification to or deviation from this flow very fundamentally changes how interactors work and is likely to result in undefined behavior. Consequently, neither directly invoking nor overriding this method is recommended.
Adds an IActiveStates to a dynamically instantiated Interactor.
This method exists to support Interaction SDK's dependency injection pattern and is not needed for typical Unity Editor-based usage.
Adds a set of IGameObjectFilters to a dynamically instantiated Interactor.
This method exists to support Interaction SDK's dependency injection pattern and is not needed for typical Unity Editor-based usage.
Adds an ICandidateComparers to a dynamically instantiated Interactor.
This method exists to support Interaction SDK's dependency injection pattern and is not needed for typical Unity Editor-based usage.
Sets Data property on a dynamically instantiated Interactor.
This method exists to support Interaction SDK's dependency injection pattern and is not needed for typical Unity Editor-based usage.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon