Show / Hide Table of Contents

    Class Interactable

    Uses input and action data to declare a set of states Maintains a collection of themes that react to state changes and provide sensory feedback Passes state information and input data on to receivers that detect patterns and does stuff.

    Inheritance
    Object
    Interactable
    Implements
    IMixedRealityFocusChangedHandler
    IMixedRealityFocusHandler
    IMixedRealityInputHandler
    IMixedRealitySpeechHandler
    IMixedRealityTouchHandler
    IMixedRealityInputHandler<Vector2>
    IMixedRealityInputHandler<Vector3>
    IMixedRealityInputHandler<MixedRealityPose>
    Namespace: Microsoft.MixedReality.Toolkit.UI
    Assembly: cs.temp.dll.dll
    Syntax
    [Serializable]
    public class Interactable : MonoBehaviour, IMixedRealityFocusChangedHandler, IMixedRealityFocusHandler, IMixedRealityInputHandler, IMixedRealitySpeechHandler, IMixedRealityTouchHandler, IMixedRealityInputHandler<Vector2>, IMixedRealityInputHandler<Vector3>, IMixedRealityInputHandler<MixedRealityPose>

    Fields

    CanDeselect

    Can the user deselect a toggle? A radial button or tab should set this to false

    Declaration
    public bool CanDeselect
    Field Value
    Type Description
    Boolean

    CanSelect

    Is the interactive selectable? When a multi-dimension button, can the user initiate switching dimensions?

    Declaration
    public bool CanSelect
    Field Value
    Type Description
    Boolean

    clickCount

    Declaration
    protected int clickCount
    Field Value
    Type Description
    Int32

    clickTime

    Declaration
    protected float clickTime
    Field Value
    Type Description
    Single

    clickValidTimer

    Declaration
    protected Coroutine clickValidTimer
    Field Value
    Type Description
    Coroutine

    dimensionIndex

    Declaration
    protected int dimensionIndex
    Field Value
    Type Description
    Int32

    Dimensions

    A way of adding more layers of states for controls like toggles

    Declaration
    public int Dimensions
    Field Value
    Type Description
    Int32

    dragStartPosition

    The position of the controller when input down occurs. Used to determine when controller has moved far enough to trigger gesture

    Declaration
    protected Vector3? dragStartPosition
    Field Value
    Type Description
    Nullable<Vector3>

    Enabled

    Is the interactable enabled?

    Declaration
    public bool Enabled
    Field Value
    Type Description
    Boolean

    Events

    List of events added to this interactable

    Declaration
    public List<InteractableEvent> Events
    Field Value
    Type Description
    List<InteractableEvent>

    focusingPointers

    Declaration
    protected readonly List<IMixedRealityPointer> focusingPointers
    Field Value
    Type Description
    List<IMixedRealityPointer>

    forceUpdate

    Declaration
    protected bool forceUpdate
    Field Value
    Type Description
    Boolean

    globalFeedbackClickTime

    Declaration
    protected float globalFeedbackClickTime
    Field Value
    Type Description
    Single

    globalTimer

    Declaration
    protected Coroutine globalTimer
    Field Value
    Type Description
    Coroutine

    handlers

    Declaration
    protected List<IInteractableHandler> handlers
    Field Value
    Type Description
    List<IInteractableHandler>

    InputAction

    Which action is this interactable listening for

    Declaration
    public MixedRealityInputAction InputAction
    Field Value
    Type Description
    MixedRealityInputAction

    InputActionId

    Declaration
    public int InputActionId
    Field Value
    Type Description
    Int32

    IsGlobal

    Is the interactable listening to global events (input only)

    Declaration
    public bool IsGlobal
    Field Value
    Type Description
    Boolean

    isGlobalValueCheck

    Declaration
    protected bool isGlobalValueCheck
    Field Value
    Type Description
    Boolean

    lastState

    Declaration
    protected State lastState
    Field Value
    Type Description
    State

    OnClick

    Base onclick event

    Declaration
    public UnityEvent OnClick
    Field Value
    Type Description
    UnityEvent

    pressingInputSources

    Declaration
    protected readonly HashSet<IMixedRealityInputSource> pressingInputSources
    Field Value
    Type Description
    HashSet<IMixedRealityInputSource>

    Profiles

    List of profiles can match themes with gameObjects

    Declaration
    public List<InteractableProfileItem> Profiles
    Field Value
    Type Description
    List<InteractableProfileItem>

    RequiresFocus

    Does the voice command require this to have focus? Registers as a global listener for speech commands, ignores input events

    Declaration
    public bool RequiresFocus
    Field Value
    Type Description
    Boolean

    requiresFocusValueCheck

    Declaration
    protected bool requiresFocusValueCheck
    Field Value
    Type Description
    Boolean

    rollOffTime

    Declaration
    protected float rollOffTime
    Field Value
    Type Description
    Single

    rollOffTimer

    Declaration
    protected float rollOffTimer
    Field Value
    Type Description
    Single

    runningProfileSettings

    Declaration
    protected List<ProfileSettings> runningProfileSettings
    Field Value
    Type Description
    List<ProfileSettings>

    runningThemesList

    The list of running theme instances to receive state changes When the dimension index changes, the list of themes that are updated changes to those assigned to that dimension.

    Declaration
    public List<InteractableThemeBase> runningThemesList
    Field Value
    Type Description
    List<InteractableThemeBase>

    StateManager

    The state logic for comparing state

    Declaration
    public InteractableStates StateManager
    Field Value
    Type Description
    InteractableStates

    States

    A collection of states and basic state logic

    Declaration
    public States States
    Field Value
    Type Description
    States

    VoiceCommand

    A voice command to fire a click event

    Declaration
    public string VoiceCommand
    Field Value
    Type Description
    String

    voiceCommands

    Declaration
    protected string[] voiceCommands
    Field Value
    Type Description
    String[]

    wasDisabled

    Declaration
    protected bool wasDisabled
    Field Value
    Type Description
    Boolean

    Properties

    ClickCount

    how many times this interactable was clicked good for checking when a click event occurs.

    Declaration
    public int ClickCount { get; }
    Property Value
    Type Description
    Int32

    FocusEnabled

    Does this interactable require focus

    Declaration
    public bool FocusEnabled { get; set; }
    Property Value
    Type Description
    Boolean

    FocusingPointers

    Pointers that are focusing the interactable

    Declaration
    public List<IMixedRealityPointer> FocusingPointers { get; }
    Property Value
    Type Description
    List<IMixedRealityPointer>

    HasCollision

    Interactable is touching another object - custom: not set by Interactable

    Declaration
    public bool HasCollision { get; }
    Property Value
    Type Description
    Boolean

    HasCustom

    Misc - custom: not set by Interactable

    Declaration
    public bool HasCustom { get; }
    Property Value
    Type Description
    Boolean

    HasFocus

    Has focus

    Declaration
    public bool HasFocus { get; }
    Property Value
    Type Description
    Boolean

    HasGesture

    Currently pressed and some movement has occurred

    Declaration
    public bool HasGesture { get; }
    Property Value
    Type Description
    Boolean

    HasGestureMax

    Gesture reached max threshold or limits - custom: not set by Interactable

    Declaration
    public bool HasGestureMax { get; }
    Property Value
    Type Description
    Boolean

    HasGrab

    A near interaction grabbable is actively being grabbed/

    Declaration
    public bool HasGrab { get; }
    Property Value
    Type Description
    Boolean

    HasObservation

    No focus, finger down - custom: not set by Interactable

    Declaration
    public bool HasObservation { get; }
    Property Value
    Type Description
    Boolean

    HasObservationTargeted

    Has focus, finger down - custom: not set by Interactable

    Declaration
    public bool HasObservationTargeted { get; }
    Property Value
    Type Description
    Boolean

    HasPhysicalTouch

    A near interaction touchable is actively being touched

    Declaration
    public bool HasPhysicalTouch { get; }
    Property Value
    Type Description
    Boolean

    HasPress

    Currently being pressed

    Declaration
    public bool HasPress { get; }
    Property Value
    Type Description
    Boolean

    HasVoiceCommand

    A voice command has occurred, this does not automatically reset Can be reset using the SetVoiceCommand(bool) method.

    Declaration
    public bool HasVoiceCommand { get; }
    Property Value
    Type Description
    Boolean

    InputSystem

    Declaration
    protected static IMixedRealityInputSystem InputSystem { get; }
    Property Value
    Type Description
    IMixedRealityInputSystem

    IsDisabled

    Is disabled

    Declaration
    public bool IsDisabled { get; }
    Property Value
    Type Description
    Boolean

    IsInteractive

    No focus, finger is up - custom: not set by Interactable

    Declaration
    public bool IsInteractive { get; }
    Property Value
    Type Description
    Boolean

    IsTargeted

    Has focus, finger up - custom: not set by Interactable

    Declaration
    public bool IsTargeted { get; }
    Property Value
    Type Description
    Boolean

    IsToggled

    True if SelectionMode is "Toggle" (Dimensions == 2) and the dimension index is not zero.

    Declaration
    public bool IsToggled { get; }
    Property Value
    Type Description
    Boolean

    IsVisited

    The Interactable has been clicked

    Declaration
    public bool IsVisited { get; }
    Property Value
    Type Description
    Boolean

    PressingInputSources

    Input sources that are pressing the interactable

    Declaration
    public HashSet<IMixedRealityInputSource> PressingInputSources { get; }
    Property Value
    Type Description
    HashSet<IMixedRealityInputSource>

    Methods

    AddHandler(IInteractableHandler)

    Register OnClick extra handlers

    Declaration
    public void AddHandler(IInteractableHandler handler)
    Parameters
    Type Name Description
    IInteractableHandler handler

    Awake()

    Declaration
    protected virtual void Awake()

    CanInteract()

    Based on button settings and state, should this button listen to input?

    Declaration
    protected virtual bool CanInteract()
    Returns
    Type Description
    Boolean

    DecreaseDimension()

    a public way to decrease the dimension

    Declaration
    public void DecreaseDimension()

    FilterThemesByDimensions()

    Get the themes based on the current dimesionIndex

    Declaration
    protected void FilterThemesByDimensions()

    ForceUpdateThemes()

    Declaration
    public void ForceUpdateThemes()

    GetDimensionIndex()

    A public way to access the current dimension

    Declaration
    public int GetDimensionIndex()
    Returns
    Type Description
    Int32

    GetStates()

    Returns a list of states assigned to the Interactable

    Declaration
    public State[] GetStates()
    Returns
    Type Description
    State[]

    GetStateValue(InteractableStates.InteractableStateEnum)

    Grabs the state value index

    Declaration
    public int GetStateValue(InteractableStates.InteractableStateEnum state)
    Parameters
    Type Name Description
    InteractableStates.InteractableStateEnum state
    Returns
    Type Description
    Int32

    GetVoiceCommandIndex(String)

    checks the voiceCommand array for a keyword and returns it's index

    Declaration
    protected int GetVoiceCommandIndex(string command)
    Parameters
    Type Name Description
    String command
    Returns
    Type Description
    Int32

    GlobalVisualReset(Single)

    Clears up any automated visual states

    Declaration
    protected IEnumerator GlobalVisualReset(float time)
    Parameters
    Type Name Description
    Single time
    Returns
    Type Description
    IEnumerator

    IncreaseDimension()

    a public way to increase a dimension, for cycle button

    Declaration
    public void IncreaseDimension()

    IncreaseDimensionIndex()

    internal dimension cycling

    Declaration
    protected void IncreaseDimensionIndex()

    InputDownTimer(Single)

    A timer for the MixedRealityInputHandlers, clicks should occur within a certain time.

    Declaration
    protected IEnumerator InputDownTimer(float time)
    Parameters
    Type Name Description
    Single time
    Returns
    Type Description
    IEnumerator

    OnBeforeFocusChange(FocusEventData)

    Declaration
    public void OnBeforeFocusChange(FocusEventData eventData)
    Parameters
    Type Name Description
    FocusEventData eventData

    OnFocusChanged(FocusEventData)

    Declaration
    public void OnFocusChanged(FocusEventData eventData)
    Parameters
    Type Name Description
    FocusEventData eventData

    OnFocusEnter(FocusEventData)

    Declaration
    public void OnFocusEnter(FocusEventData eventData)
    Parameters
    Type Name Description
    FocusEventData eventData

    OnFocusExit(FocusEventData)

    Declaration
    public void OnFocusExit(FocusEventData eventData)
    Parameters
    Type Name Description
    FocusEventData eventData

    OnInputChanged(InputEventData<MixedRealityPose>)

    Declaration
    public void OnInputChanged(InputEventData<MixedRealityPose> eventData)
    Parameters
    Type Name Description
    InputEventData<MixedRealityPose> eventData

    OnInputChanged(InputEventData<Vector2>)

    Declaration
    public void OnInputChanged(InputEventData<Vector2> eventData)
    Parameters
    Type Name Description
    InputEventData<Vector2> eventData

    OnInputChanged(InputEventData<Vector3>)

    Declaration
    public void OnInputChanged(InputEventData<Vector3> eventData)
    Parameters
    Type Name Description
    InputEventData<Vector3> eventData

    OnInputDown(InputEventData)

    Declaration
    public void OnInputDown(InputEventData eventData)
    Parameters
    Type Name Description
    InputEventData eventData

    OnInputUp(InputEventData)

    Declaration
    public void OnInputUp(InputEventData eventData)
    Parameters
    Type Name Description
    InputEventData eventData

    OnPositionInputChanged(InputEventData<Vector2>)

    Declaration
    public void OnPositionInputChanged(InputEventData<Vector2> eventData)
    Parameters
    Type Name Description
    InputEventData<Vector2> eventData

    OnSpeechKeywordRecognized(SpeechEventData)

    Voice commands from MixedRealitySpeechCommandProfile, keyword recognized requires isGlobal

    Declaration
    public void OnSpeechKeywordRecognized(SpeechEventData eventData)
    Parameters
    Type Name Description
    SpeechEventData eventData

    OnTouchCompleted(HandTrackingInputEventData)

    Declaration
    public void OnTouchCompleted(HandTrackingInputEventData eventData)
    Parameters
    Type Name Description
    HandTrackingInputEventData eventData

    OnTouchStarted(HandTrackingInputEventData)

    Declaration
    public void OnTouchStarted(HandTrackingInputEventData eventData)
    Parameters
    Type Name Description
    HandTrackingInputEventData eventData

    OnTouchUpdated(HandTrackingInputEventData)

    Declaration
    public void OnTouchUpdated(HandTrackingInputEventData eventData)
    Parameters
    Type Name Description
    HandTrackingInputEventData eventData

    RemoveHandler(IInteractableHandler)

    Remove onClick handlers

    Declaration
    public void RemoveHandler(IInteractableHandler handler)
    Parameters
    Type Name Description
    IInteractableHandler handler

    ResetAllStates()

    Reset all states in the Interactable and pointer information

    Declaration
    public void ResetAllStates()

    ResetBaseStates()

    Reset the basic interaction states

    Declaration
    public void ResetBaseStates()

    ResolveInputAction(Int32)

    Assigns the InputAction based on the InputActionId

    Declaration
    public static MixedRealityInputAction ResolveInputAction(int index)
    Parameters
    Type Name Description
    Int32 index
    Returns
    Type Description
    MixedRealityInputAction

    SendOnClick(IMixedRealityPointer)

    call onClick methods on receivers or IInteractableHandlers

    Declaration
    protected void SendOnClick(IMixedRealityPointer pointer)
    Parameters
    Type Name Description
    IMixedRealityPointer pointer

    SendVoiceCommands(String, Int32, Int32)

    call OnVoinceCommand methods on receivers or IInteractableHandlers

    Declaration
    protected void SendVoiceCommands(string command, int index, int length)
    Parameters
    Type Name Description
    String command
    Int32 index
    Int32 length

    SetCollision(Boolean)

    Change the collision state

    Declaration
    public virtual void SetCollision(bool collision)
    Parameters
    Type Name Description
    Boolean collision

    SetCustom(Boolean)

    Change the custom state

    Declaration
    public virtual void SetCustom(bool custom)
    Parameters
    Type Name Description
    Boolean custom

    SetDimensionIndex(Int32)

    a public way to set the dimension index

    Declaration
    public void SetDimensionIndex(int index)
    Parameters
    Type Name Description
    Int32 index

    SetDisabled(Boolean)

    Change the disabled state, will override the Enabled property

    Declaration
    public virtual void SetDisabled(bool disabled)
    Parameters
    Type Name Description
    Boolean disabled

    SetFocus(Boolean)

    Handle focus state changes

    Declaration
    public virtual void SetFocus(bool focus)
    Parameters
    Type Name Description
    Boolean focus

    SetGesture(Boolean)

    Change the gesture state

    Declaration
    public virtual void SetGesture(bool gesture)
    Parameters
    Type Name Description
    Boolean gesture

    SetGestureMax(Boolean)

    Change the gesture max state

    Declaration
    public virtual void SetGestureMax(bool gesture)
    Parameters
    Type Name Description
    Boolean gesture

    SetGrab(Boolean)

    Change the grab state

    Declaration
    public virtual void SetGrab(bool grab)
    Parameters
    Type Name Description
    Boolean grab

    SetInputDown()

    Public method that can be used to set state of interactable corresponding to an input going down (select button, menu button, touch)

    Declaration
    public void SetInputDown()

    SetInputUp()

    Public method that can be used to set state of interactable corresponding to an input going up.

    Declaration
    public void SetInputUp()

    SetInteractive(Boolean)

    Change the Interactive state

    Declaration
    public virtual void SetInteractive(bool interactive)
    Parameters
    Type Name Description
    Boolean interactive

    SetObservation(Boolean)

    Change the observation state

    Declaration
    public virtual void SetObservation(bool observation)
    Parameters
    Type Name Description
    Boolean observation

    SetObservationTargeted(Boolean)

    Change the observation targeted state

    Declaration
    public virtual void SetObservationTargeted(bool targeted)
    Parameters
    Type Name Description
    Boolean targeted

    SetPhysicalTouch(Boolean)

    Change the physical touch state

    Declaration
    public virtual void SetPhysicalTouch(bool touch)
    Parameters
    Type Name Description
    Boolean touch

    SetPress(Boolean)

    Change the press state

    Declaration
    public virtual void SetPress(bool press)
    Parameters
    Type Name Description
    Boolean press

    SetState(InteractableStates.InteractableStateEnum, Boolean)

    a public way to set state directly

    Declaration
    public void SetState(InteractableStates.InteractableStateEnum state, bool value)
    Parameters
    Type Name Description
    InteractableStates.InteractableStateEnum state
    Boolean value

    SetTargeted(Boolean)

    Change the targeted state

    Declaration
    public virtual void SetTargeted(bool targeted)
    Parameters
    Type Name Description
    Boolean targeted

    SetToggled(Boolean)

    Change the toggled state

    Declaration
    public virtual void SetToggled(bool toggled)
    Parameters
    Type Name Description
    Boolean toggled

    SetupEvents()

    Creates the event receiver instances from the Events list

    Declaration
    protected virtual void SetupEvents()

    SetupStates()

    starts the StateManager

    Declaration
    protected virtual void SetupStates()

    SetupThemes()

    Creates the list of theme instances based on all the theme settings

    Declaration
    protected virtual void SetupThemes()

    SetVisited(Boolean)

    Change the visited state

    Declaration
    public virtual void SetVisited(bool visited)
    Parameters
    Type Name Description
    Boolean visited

    SetVoiceCommand(Boolean)

    Change the voice command state

    Declaration
    public virtual void SetVoiceCommand(bool voice)
    Parameters
    Type Name Description
    Boolean voice

    ShouldListenToUpDownEvent(InputEventData)

    Based on inputAction and state, should interactable listen to this up/down event.

    Declaration
    protected virtual bool ShouldListenToUpDownEvent(InputEventData data)
    Parameters
    Type Name Description
    InputEventData data
    Returns
    Type Description
    Boolean

    Start()

    Declaration
    protected virtual void Start()

    StartClickTimer(Boolean)

    Starts a timer to check if input is in progress

    • Make sure global pointer events are not double firing
    • Make sure Global Input events are not double firing
    • Make sure pointer events are not duplicating an input event
    Declaration
    protected void StartClickTimer(bool isFromInputDown = false)
    Parameters
    Type Name Description
    Boolean isFromInputDown

    StartGlobalVisual(Boolean)

    sets some visual states for automating button events like clicks from a keyword

    Declaration
    protected void StartGlobalVisual(bool voiceCommand = false)
    Parameters
    Type Name Description
    Boolean voiceCommand

    StopClickTimer()

    Declaration
    protected void StopClickTimer()

    TriggerOnClick()

    A public way to trigger or route an onClick event from an external source, like PressableButton

    Declaration
    public void TriggerOnClick()

    TryGetInputActions(out String[])

    Get a list of Mixed Reality Input Actions from the input actions profile.

    Declaration
    public static bool TryGetInputActions(out string[] descriptionsArray)
    Parameters
    Type Name Description
    String[] descriptionsArray
    Returns
    Type Description
    Boolean

    TryGetMixedRealitySpeechCommands(out SpeechCommands[])

    Try to get a list of speech commands from the MRTK/Input/SpeechCommands profile

    Declaration
    public static bool TryGetMixedRealitySpeechCommands(out SpeechCommands[] commands)
    Parameters
    Type Name Description
    SpeechCommands[] commands
    Returns
    Type Description
    Boolean

    TryGetSpeechKeywords(out String[])

    Look for speech commands in the MRTK Speech Command profile Adds a blank value at index zero so the developer can turn the feature off.

    Declaration
    public static bool TryGetSpeechKeywords(out string[] keywords)
    Parameters
    Type Name Description
    String[] keywords
    Returns
    Type Description
    Boolean

    Update()

    Declaration
    protected virtual void Update()

    UpdateState()

    runs the state logic and sets state based on the current state values

    Declaration
    protected virtual void UpdateState()

    Implements

    IMixedRealityFocusChangedHandler
    IMixedRealityFocusHandler
    IMixedRealityInputHandler
    IMixedRealitySpeechHandler
    IMixedRealityTouchHandler
    IMixedRealityInputHandler<>
    IMixedRealityInputHandler<>
    IMixedRealityInputHandler<>
    Back to top Generated by DocFX