Input Data Provider

  • InputDataProvider is script that extends HandSkeletonPoseProvider with certain VR input specific functionalities and properties

  • It is an abstract class since it can't provide all the input handling functionality, therefore it is expected to be implemented by more specific input handling scripts

  • InputDataProvider contains properties that are common to many VR input sources, but it does not manipulate some of those properties itself, it is expected from derived behaviours to set them as needed using InpuDataProvider's certain protected API

  • This script executes both during edit- and run-time by default. This way changes that occur from manipulating certain properties on it can be immediately observed in Unity editor without the need to start the play mode

In addition to properties and other members inherited from HandSkeletonPoseProvider, InputDataProvider defines:

Public properties

Transform InputRoot { get; set; }

  • Transform that acts as a reference space for bone poses when they are being set by the InputDataProvider, i.e. it acts as if it was the parent to all bone poses, including root pose, when first obtained from any source. This property is defined in InputDataProvider, but it is up to behaviours that inherit from it to apply this transform as intended. It should act as an offset that is applied to the original bone poses obtained from a specific source from which the original poses are obtained (hand tracking API for example)

  • This property is exposed in the InputDataProvider's inspector panel, it should be optional, but again, it is up to the behaviours that implement InputDataProvider to implement the desired behaviour and requirements

Transform RootPoseOffset { get; set; }

  • Transform whose local position and local rotation specify the offset to apply to the final root pose provided by the InputDataProvider. This property is similar to the InputRoot, but the main difference is that the RootPoseOffset is applied at the end of root pose calculation, i.e. after the InputRoot is applied, and its local position and rotation is considered, not the world-space one

  • This property is exposed in the InputDataProvider's inspector panel, it should be optional, but again, it is up to the behaviours that implement InputDataProvider to implement the desired behaviour and requirements

bool IsTracking { get; }

  • Indicates whether the input source is tracked currently. Usually when dealing with VR input, input source can be tracked and tracking can be lost as well, e.g. hand tracking can be periodically unavailable, controller tracking too

  • This property is also available in the inspector panel of the InputDataProvider. It can be checked/unchecked there, i.e. it is not read-only in the inspector, so the user gets the opportunity to try the effects of changing it in the editor with no need to enter play mode

UnityEvent OnTrackingStart { get; }

  • Event sent when input source tracking is (re-)established, i.e. any time IsTracking changes from false to true

  • Visible in the inspector panel and sent in edit mode too

UnityEvent OnTrackingLost { get; }

  • Event sent when input source tracking gets lost, i.e. any time IsTracking changes from true to false

  • Visible in the inspector panel and sent in edit mode too

float Confidence { get; }

  • A [0, 1] ranged value that specifies confidence level of input source tracking. Some VR input sources can be at different levels of tracking confidence, this value describes how confident is tracking, 0 being not confident at all and 1 being maximum level of confidence. This value is always 0 if IsTracking is false

  • Like IsTracking, this property is visible in the inspector panel and it can be changed there to observe the effects in edit mode, but only if IsTracking is true

Protected properties

float Confidence { set; }

  • Protected setter of the previously described Confidence property, derived behaviours should set the confidence level of their input sources using this. Value being set is always clamped to [0, 1] range. Nothing is set if IsTracking is false - as mentioned, confidence level is always zero in that case

Protected methods

void SetIsTracking(bool isTracking)

  • Method for derived behaviours to use when input source tracking state needs to be updated. This method will handle all the tracking related events sending along with other callbacks described below. It has no effect if the InputDataProvider is not active and enabled

Pose GetRootPose(Pose baseRootPose)

  • Calculates the final root pose from the base pose specified by the 'baseRootPose' parameter

  • This method can be used by derived behaviours in order to calculate the final root pose to provide, InputRoot and RootPoseOffset will be applied to the initial root pose as intended using this method

virtual void InputRootChanged(Transform previousRoot)

  • Method used as callback only, for derived behaviours to override should they have a need to handle InputRoot Transform being changed. Previous Transform that was used as input root is sent as argument

virtual void TrackingStart()

  • Callback sent under same circumstances as the OnTrackingStart event, but this is called by the InputDataProvider just before the event is sent in case deriving classes need to handle tracking state change before any of the other potential subscribers of the OnTrackingStart event get the chance to do so as well

virtual void TrackingLost()

  • Same as the TrackingStart, but goes in tandem with the OnTrackingLost event and circumstances

virtual void OnValidate()

  • Unity built-in callback, keeps the state of InputDataProvider valid

  • If overridden by a derived class, base.OnValidate should always be called

virtual void OnDisable()

  • Unity built-in callback, sets the IsTracking to false. Basically this ensures that tracking is always considered absent as long as the InputDataProvider is disabled and/or inactive

  • If overridden by a derived class, base.OnDisable should always be called due to the intended behaviour of the InputDataProvider

Last updated