Input Confidence Trigger
This script acts as a trigger for input confidence level getting above or below certain threshold
It reads the confidence level (the value of Confidence property) from a InputDataProvider which is assigned to it and whenever that value crosses certain threshold value, which is also assigned, it sends out the appropriate event - one for confidence level crossing above threshold and one for confidence level crossing bellow threshold
It has a number of overridable callback methods related to that functionality as well, so behaviours inheriting from it can implement their own specific confidence level based logic
Public properties
InputDataProvider InputDataProvider { get; set; }
InputDataProvider whose confidence level is base for the trigger. This can be null, but note that in that case InputConfidenceTrigger is going to act as if the confidence level is 0, so event for low confidence level might get sent after null has been assigned
Visible and assignable in the InputConfidenceTrigger's inspector panel
float ConfidenceThreshold { get; set; }
Threshold confidence level for trigger. If the InputDataProvider's confidence level gets above this threshold or is equal to it then high confidence logic is triggered, if it gets below then low confidence logic is triggered
Visible and editable in the InputConfidenceTrigger's inspector panel. Note that using the inspector only values ranging from 0 to 1 (inclusive) can be assigned, but from code any value is valid
bool IsConfidenceLowTriggered { get; }
Specifies whether the low confidence logic has been triggered and is active at the moment. This is not neccessarily opposite of IsConfidenceHighTriggered, in some circumstances both properties can be false, but they are never both true
bool IsConfidenceHighTriggered { get; }
Same as IsConfidenceLowTriggered, but obviously this one is for high confidence logic
UnityEvent OnConfidenceLow { get; }
Event sent when low confidence logic is triggered. Visible in the inspector
UnityEvent OnConfidenceHigh { get; }
Event sent when high confidence logic is triggered. Visible in the inspector
InputConfidenceTriggerEvaluationRun TriggerEvaluationRun { get; set; }
Specifies when the InputConfidenceTrigger evaluates confidence level from its InputDataProvider. Possible values are Update, FixedUpdate and both. Depending on this, confidence low/high logic is triggered either from Update method or FixedUpdate or both
Visible and editable in the inspector panel
Protected methods
virtual void HandleConfidenceLow()
Callback method that can be overriden by derived classes in order to be notified about confidence level changing from high to low. This is called just before the OnConfidenceLow event is sent
virtual void HandleConfidenceHigh()
Callback method that can be overriden by derived classes in order to be notified about confidence level changing from low to high. This is called just before the OnConfidenceHigh event is sent
virtual void UpdateConfidenceLow()
Callback method that gets called during low confidence logic. Unlike the HandleConfidenceLow method that gets called only when confidence level crosses from high to low, this method is called every frame as long as the confidence level is below threshold (low). It gets called from Update or FixedUpdate or both methods, depending on the TriggerEvaluationRun value. It is called in the same frames as HandleConfidenceLow as well
virtual void UpdateConfidenceHigh()
Callback method that gets called during high confidence logic. Unlike the HandleConfidenceHigh method that gets called only when confidence level crosses from low to high, this method is called every frame as long as the confidence level is above threshold (high). It gets called from Update or FixedUpdate or both methods, depending on the TriggerEvaluationRun value. It is called in the same frames as HandleConfidenceHigh as well
There are several scripts included in OctoXR that derive from InputConfidenceTrigger to provide more specialized confidence level based behaviours which can be used in some common scenarios.
The following sections briefly describe those behaviours.
Input Confidence Based Component Toggler
Input confidence trigger that toggles, i.e. enables or disables components based on whether the input data confidence value is below or above the desired threshold defined in the input confidence trigger
Target components to toggle can be assigned in the inspector panel of the InputConfidenceBasedComponentToggler, they can also be added/removed in code at any time
The exact type of references that can be assigned is UnityEngine.Component, but the component toggler can only toggle the ones that inherit from UnityEngine.Behaviour or UnityEngine.Renderer since they are the ones that have 'enabled' property defined. Component toggler will not perform any action on the ones not derived from either of those two types
For each component assigned there is an option that can be set (checked or unchecked in the inspector or have a true/false value assigned in code) which specifies whether the corresponding component should be enabled when confidence level is high and disabled when it is low or the other way around - disabled when confidence level is high and enabled when it is low
Input Confidence Based GameObject Toggler
This script is basically the equivalent of InputConfidenceBasedComponentToggler described above, but for GameObjects
It activates/deactivates assigned GameObjects based on confidence level of the associated input data provider and offers the same options for each assigned GameObject as does the InputConfidenceBasedComponentToggler for each of its components
Input Confidence Based Hand Skeleton Toggler
This toggler is to a certain extent a combination of the previous two, except it is specialized to toggle one or more HandSkeletons
Each HandSkeleton assigned can be toggled in two ways and it is also possible to specify which part of it should be toggled. Parts that can be toggled are the HandSkeleton itself or its bones (HandBones assigned to it) and ways to toggle them are either by enabling/disabling components (HandSkeleton script/HandBone scripts) or by activating/deactivating the GameObjects they are attached to
The functionality this particular toggler script provides can likely be achieved with either of the previously described ones, but it does offer slightly more options than those two and it can be easier to configure in order to achieve the exact desired behaviour when HandSkeletons are involved
Last updated