API reference

Interactable Class

Extends MonoBehaviour
Implements IInteractable
Base class for most concrete interactable types.
New interactables can be created by inheriting from this class directly; however, it is also common for new interactables to inherit from PointerInteractable<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 TInteractable , which should be the concrete interactable type which derives from this type and is uniquely associated with TInteractor .

Protected Fields

_started : bool
Signature
bool _started

Properties

Data : object
[Get]
Implementation of IInteractableView.Data; for details, please refer to the related documentation provided for that interface.
Signature
object Data
Interactors : IEnumerableHashSet< TInteractor >
[Get]
Enumerates all the TInteractor s currently associated with this instance.
This list is identical to that returned by InteractorViews, but the returned elements are of type TInteractor instead of IInteractorView.
Signature
IEnumerableHashSet<TInteractor> Interactors
InteractorViews : IEnumerable< IInteractorView >
[Get]
Implementation of IInteractableView.InteractorViews; for details, please refer to the related documentation provided for that interface.
Signature
IEnumerable<IInteractorView> InteractorViews
MaxInteractors : int
[Get][Set]
Implementation of IInteractableView.MaxInteractors; for details, please refer to the related documentation provided for that interface.
Signature
int MaxInteractors
MaxSelectingInteractors : int
[Get][Set]
Implementation of IInteractableView.MaxSelectingInteractors; for details, please refer to the related documentation provided for that interface.
Signature
int MaxSelectingInteractors
Registry : InteractableRegistry< TInteractor, TInteractable >
[Get]
Retrieves the InteractableRegistry<TInteractor, TInteractable> for the concrete interactable type TInteractable .
The interactable registry is a static global container which, at any given moment, contains all the TInteractable s extant and enabled at that moment.
Signature
InteractableRegistry<TInteractor, TInteractable> Registry
SelectingInteractors : IEnumerableHashSet< TInteractor >
[Get]
Enumerates all the TInteractor s currently selecting this instance.
This list is identical to that returned by SelectingInteractorViews, but the returned elements are of type TInteractor instead of IInteractorView.
Signature
IEnumerableHashSet<TInteractor> SelectingInteractors
SelectingInteractorViews : IEnumerable< IInteractorView >
[Get]
Implementation of IInteractableView.SelectingInteractorViews; for details, please refer to the related documentation provided for that interface.
Signature
IEnumerable<IInteractorView> SelectingInteractorViews
State : InteractableState
[Get]
Implementation of IInteractableView.State; for details, please refer to the related documentation provided for that interface.
Signature
InteractableState State
WhenInteractorAdded : MAction< TInteractor >
[Get]
An event indicating that a new interactor has been added to InteractorViews.
In terms of InteractableState, this occurs when this interactable is hovered by a new interactor.
Signature
MAction<TInteractor> WhenInteractorAdded
WhenInteractorRemoved : MAction< TInteractor >
[Get]
An event indicating that an interactor has been removed from InteractorViews.
In terms of InteractableState, this occurs when this interactable ceases to be hovered by an interactor.
Signature
MAction<TInteractor> WhenInteractorRemoved
WhenSelectingInteractorAdded : MAction< TInteractor >
[Get]
An event indicating that a new interactor has been added to SelectingInteractorViews.
In terms of InteractableState, this occurs when this interactable is selected by a new interactor.
Signature
MAction<TInteractor> WhenSelectingInteractorAdded
WhenSelectingInteractorRemoved : MAction< TInteractor >
[Get]
An event indicating that an interactor has been removed from SelectingInteractorViews.
In terms of InteractableState, this occurs when this interactable ceases to be selected by an interactor.
Signature
MAction<TInteractor> WhenSelectingInteractorRemoved

Events

WhenInteractorViewAdded : Action< IInteractorView >
Implementation of IInteractableView.WhenInteractorViewAdded; for details, please refer to the related documentation provided for that interface.
Signature
Action<IInteractorView> WhenInteractorViewAdded
WhenInteractorViewRemoved : Action< IInteractorView >
Implementation of IInteractableView.WhenInteractorViewRemoved; for details, please refer to the related documentation provided for that interface.
Signature
Action<IInteractorView> WhenInteractorViewRemoved
WhenSelectingInteractorViewAdded : Action< IInteractorView >
Implementation of IInteractableView.WhenSelectingInteractorViewAdded; for details, please refer to the related documentation provided for that interface.
Signature
Action<IInteractorView> WhenSelectingInteractorViewAdded
WhenSelectingInteractorViewRemoved : Action< IInteractorView >
Implementation of IInteractableView.WhenSelectingInteractorViewRemoved; for details, please refer to the related documentation provided for that interface.
Signature
Action<IInteractorView> WhenSelectingInteractorViewRemoved
WhenStateChanged : Action< InteractableStateChangeArgs >
Implementation of IInteractableView.WhenStateChanged; for details, please refer to the related documentation provided for that interface.
Signature
Action<InteractableStateChangeArgs> WhenStateChanged

Protected Methods

Awake ()
Signature
virtual void Awake()
Returns
void
InteractorAdded ( interactor )
Signature
virtual void InteractorAdded(TInteractor interactor)
Parameters
interactor: TInteractor
Returns
void
InteractorRemoved ( interactor )
Signature
virtual void InteractorRemoved(TInteractor interactor)
Parameters
interactor: TInteractor
Returns
void
OnDisable ()
Signature
virtual void OnDisable()
Returns
void
OnEnable ()
Signature
virtual void OnEnable()
Returns
void
SelectingInteractorAdded ( interactor )
Signature
virtual void SelectingInteractorAdded(TInteractor interactor)
Parameters
interactor: TInteractor
Returns
void
SelectingInteractorRemoved ( interactor )
Signature
virtual void SelectingInteractorRemoved(TInteractor interactor)
Parameters
interactor: TInteractor
Returns
void
SetRegistry ( registry )
Signature
virtual void SetRegistry(InteractableRegistry< TInteractor, TInteractable > registry)
Parameters
registry: InteractableRegistry< TInteractor, TInteractable >
Returns
void
Start ()
Signature
virtual void Start()
Returns
void

Methods

AddInteractor ( interactor )
Adds a TInteractor to this interactable instance.
This is an internal API and should only be invoked by the interactor being added; directly invoking this from outside the normal interactor processing flow risks creating an asymmetric interactor-interactable relationship (i.e., a situation where an interactor believes it is associated with an interactable in a certain way, but the interactable believes something else), which can result in undefined behavior.
Signature
void AddInteractor(TInteractor interactor)
Parameters
interactor: TInteractor
Returns
void
AddSelectingInteractor ( interactor )
Adds a TInteractor to the list of interactors selecting this interactable instance.
This is an internal API and should only be invoked by the interactor being added; directly invoking this from outside the normal interactor processing flow risks creating an asymmetric interactor-interactable relationship (i.e., a situation where an interactor believes it is associated with an interactable in a certain way, but the interactable believes something else), which can result in undefined behavior.
Signature
void AddSelectingInteractor(TInteractor interactor)
Parameters
interactor: TInteractor
Returns
void
CanBeSelectedBy ( interactor )
Determines if the interactable can be interacted on by the given interactor.
Similar to Interactor<TInteractor, TInteractable>.CanSelect(TInteractable), the specific question answered by this method is not about interaction candidacy but more about interaction possibility: it does not test whether the interactor might select this interactable, but only whether the interactor would be able to if it tried. This is a more ephemeral answer for TInteractable than for TInteractor ; enablement and number of currently active interactions (both highly variable considerations over time) factor into this test for the interactable. To emphasize this point Interactor<TInteractor, TInteractable>.CanSelect(TInteractable) and Interactable<TInteractor, TInteractable>.CanBeSelectedBy(TInteractor) are asymmetric: the fact that an interactor is capable of selecting an interactable does not imply that the interactable is capable of being selected by that interactor, nor vice versa, and both must be true in order for a valid interaction to be possible.
Signature
bool CanBeSelectedBy(TInteractor interactor)
Parameters
interactor: TInteractor  The interactor that intends to interact with the interactable.
Returns
bool  True if the interactor can interact with the interactable, false otherwise.
Disable ()
Implementation of IInteractable.Disable; for details, please refer to the related documentation provided for that interface.
Signature
void Disable()
Returns
void
Enable ()
Implementation of IInteractable.Enable; for details, please refer to the related documentation provided for that interface.
Signature
void Enable()
Returns
void
HasInteractor ( interactor )
Determines if the interactable is being hovered by the given interactor.
This is a convenience method identical to calling the Contains() method on Interactors.
Signature
bool HasInteractor(TInteractor interactor)
Parameters
interactor: TInteractor  The interactor to check for hovering.
Returns
bool  True if the interactor is hovering the interactable, false otherwise.
HasSelectingInteractor ( interactor )
Determines if the interactable is being selected by the given interactor.
This is a convenience method identical to calling the Contains() method on SelectingInteractors.
Signature
bool HasSelectingInteractor(TInteractor interactor)
Parameters
interactor: TInteractor  The interactor to check for selecting.
Returns
bool  True if the interactor is selecting the interactable, false otherwise.
InjectOptionalData ( data )
Sets the Data for this interactable on a dynamically instantiated GameObject.
This method exists to support Interaction SDK's dependency injection pattern and is not needed for typical Unity Editor-based usage.
Signature
void InjectOptionalData(object data)
Parameters
data: object
Returns
void
InjectOptionalInteractorFilters ( interactorFilters )
Sets the interactor filters for this interactable on a dynamically instantiated GameObject.
This method exists to support Interaction SDK's dependency injection pattern and is not needed for typical Unity Editor-based usage.
Signature
void InjectOptionalInteractorFilters(List< IGameObjectFilter > interactorFilters)
Parameters
interactorFilters: List< IGameObjectFilter >
Returns
void
RemoveInteractor ( interactor )
Removes a TInteractor from this interactable instance.
This is an internal API and should only be invoked by the interactor being removed; directly invoking this from outside the normal interactor processing flow risks creating an asymmetric interactor-interactable relationship (i.e., a situation where an interactor believes it is associated with an interactable in a certain way, but the interactable believes something else), which can result in undefined behavior.
Signature
void RemoveInteractor(TInteractor interactor)
Parameters
interactor: TInteractor
Returns
void
RemoveInteractorByIdentifier ( id )
Implementation of IInteractable.RemoveInteractorByIdentifier(int); for details, please refer to the related documentation provided for that interface.
Signature
void RemoveInteractorByIdentifier(int id)
Parameters
id: int
Returns
void
RemoveSelectingInteractor ( interactor )
Removes a TInteractor from the list of interactors selecting this interactable instance.
This is an internal API and should only be invoked by the interactor being removed; directly invoking this from outside the normal interactor processing flow risks creating an asymmetric interactor-interactable relationship (i.e., a situation where an interactor believes it is associated with an interactable in a certain way, but the interactable believes something else), which can result in undefined behavior.
Signature
void RemoveSelectingInteractor(TInteractor interactor)
Parameters
interactor: TInteractor
Returns
void