Multi Source Input Data Provider
Script in OctoXR that inherits from InputDataProvider and serves as a switcher between multiple InputDataProviders
It keeps a list of InputDataProviders and constantly checks for their tracking status, the first InputDataProvider in the list that is tracking its input source is taken as the current active provider - MultiSourceInputDataProvider provides the input data that is sourced from the active InputDataProvider as long as the current provider is tracking
If the current active InputDataProvider stops tracking, MultiSourceInputDataProvider will then choose a new active provider from its list based on InputDataProviders' tracking status
If no InputDataProvider that is tracking is found in the list, MultiSourceInputDataProvider will also have its tracking state disabled, i.e. IsTracking property of the MultiSourceInputDataProvider will be false, until the first InputDataProvider that starts tracking its input source is found in the list
This script enables the possibility to switch between XR controller and hand tracking input; as soon as the controller tracking is lost, hand tracking can start (assuming the XR device in use supports hand tracking) and vice-versa
Public properties
InputDataProvider Current { get; }
Input data provider that is current source of input data provided by the multi-source input data provider
Null value means there is no InputDataProvider in the MultiSourceInputDataprovider's list of source input data providers that is currently tracking its input source
This property is exposed in the Unity editor as a read-only property
HandType DefaultHandType { get; set; }
Sidedness of the hand for which the MultiSourceInputDataProvider is providing input data by default
bool RunInFixedUpdate { get; set; }
Specifies whether the MultiSourceInputDataProvider should run its logic in FixedUpdate instead of Update
List<InputDataProvider> SourceInputDataProviders { get; }
List of InputDataProviders the MultiSourceInputDataProvider uses as source if input data based on their current tracking status, i.e. MultiSourceInputDataProvider switches between them
Protected methods
override void TrackingStart()
Override of InputDataProvider's callback sent when tracking starts, ensures tracking status of MultiSourceInputDataProvider is consistent with the tracking status of its current active InputDataProvider used as source of input data
override void TrackingLost()
Override of InputDataProvider's callback sent when tracking is lost, ensures tracking status of MultiSourceInputDataProvider is consistent with the tracking status of its current active InputDataProvider used as source of input data
override void OnValidate()
Unity built-in callback, overrides base InputDataProvider's OnValidate method, ensures the state of MultiSourceInputDataProvider is valid
override void OnDisable()
Unity built-in callback, handles disabling of MultiSourceInputDataProvider
virtual void Update()
Unity built-in callback, executes the MultiSourceInputDataProvider's main logic, depending on the current play mode of Unity editor and the value set for RunInFixedUpdate
virtual void FixedUpdate()
Unity built-in callback, executes the MultiSourceInputDataProvider's main logic, depending on the current play mode of Unity editor and the value set for RunInFixedUpdate
Last updated