valuerangeinteractable - eisclimber/ExPresS-XR GitHub Wiki

ExPresSXR.Interaction.ValueRangeInteractable Namespace

Summary

Classes for value range interactables, such as sliders and levers.

Classes

Name Description
BaseValueDescriptor This class is the base implementation of a value range to define the behavior of interpolating a value.
This is currently used to hold the information needed for ExPresS XR#s ValueRangeInteractables, such as Levers, sliders, ...

You can of course create your own range by inheriting from BaseValueDescriptor (NOT ValueDescriptor !). You'll need to implement the ProcessNewValue() function to handle and return new values as you like. To define the bounds of your range also implement IsMinValue() and IsMinValue() to properly trigger the respective events. Keep in mind, that a range may have multiple min/max values. Make sure to add a [System.Serializable] attribute to your ValueDescriptor-class.

In case you want or to add attributes to your serialized value-field (like Float01Range ) you'll need to inherit from ValueDescriptor . If you to that, you will need to implement the behavior of the Value property yourself, setting your value to the return value of ProcessNewValue() and calling HandleValueChange() with the old value. It is usually sufficient to call the| |Button|Defines a button interactable.| |ButtonDescriptor|Represents the internal press value of a button represented by a value between 0.0f (up-position) and 1.0f (down-position). Allows customizing the press threshold and deadzone and repress timeouts, whilst also supporting an optional toggle mode.| |ButtonVisualizer|Defines the visualization for a slider interactable along the x-axis.| |CircularDescriptor|A range to interpolate the magnitude of a Vector2 between -1.0f and 1.0f (both inclusive), whilst supporting snapping.| |DirectionDescriptor|A range to interpolate a direction Vector3 having a magnitude of 1.0f, whilst supporting snapping.| |Float01Descriptor|A range to interpolate a float between 0.0f and 1.0f (both inclusive), whilst supporting snapping.| |Joystick|Defines a joystick interactable.| |JoystickVisualizer|Defines the visualization for a joystick interactable.| |KnobInteractable|Defines a turnable (door-) knob interactable. It features an option for turning using the wrist/controller rotation and by rotating around the up-axis. For a more complex turing behavior see: https://github.com/Unity-Technologies/XR-Interaction-Toolkit-Examples/blob/main/Assets/XRI_Examples/UI_3D/Scripts/XRKnob.cs| |Lever|Defines a lever interactable that rotates around back and forth (around the x-axis).| |LeverVisualizer|Defines the visualization for a lever interactable that rotates around back and forth (around the x-axis).| |PullbackSlider|Defines a slider interactable that automatically returns to it's' initial position after being released.| |ScrewTurnInteractable|Defines a turn interactable that also translates up and down.| |ScrewVisualizer|Defines the visualization for a turn interactable that also translates up and down.| |Slider|Defines a slider interactable along the x-axis. Please avoid rotating the interactable!| |Slider2D|Defines a two dimensional slider interactable along the xy-plane.| |Slider2DRound|Defines a two dimensional slider interactable along the xy-plane with a circular shape.| |Slider2DRoundVisualizer|Defines the visualization for a two dimensional slider interactable along the xy-plane.| |Slider2DVisualizer|Defines the visualization for a two dimensional slider interactable along the xy-plane.| |Slider3D|Defines a three dimensional slider interactable.| |Slider3DDirection|Defines a three dimensional slider interactable with a spherical shape.| |Slider3DRound|Defines a three dimensional slider interactable with a spherical shape.| |Slider3DSphereVisualizer|Defines the visualization for a three dimensional slider interactable with a spherical shape.| |Slider3DVisualizer|Defines the visualization for a three dimensional slider interactable.| |SliderVisualizer|Defines the visualization for a slider interactable along the x-axis.| |SphereDescriptor|A range to interpolate the magnitude of a Vector3 between 0.0f and 1.0f (both inclusive), whilst supporting snapping.| |TurnVisualizer|Defines the visualization for a turnable (door-)knob interactable.| |ValueDescriptor|This class is the base implementation of a value range to define the behavior of interpolating a value. This is currently used to hold the information needed for ExPresS XR#s ValueRangeInteractables, such as Levers, sliders, ...

You can of course create your own range by inheriting from BaseValueDescriptor (NOT ValueDescriptor !). You'll need to implement the ProcessNewValue() function to handle and return new values as you like. To define the bounds of your range also implement IsMinValue() and IsMinValue() to properly trigger the respective events. Keep in mind, that a range may have multiple min/max values. Make sure to add a [System.Serializable] attribute to your ValueDescriptor-class.

In case you want or to add attributes to your serialized value-field (like Float01Range ) you'll need to inherit from ValueDescriptor . If you to that, you will need to implement the behavior of the Value property yourself, setting your value to the return value of ProcessNewValue() and calling HandleValueChange() with the old value. It is usually sufficient to call the| |ValueRangeInteractable<T, U, V>|An abstract interactable base class for selecting a value on a specific range with the option to snap a value. The value as well as the behavior is described by a ValueDescriptor so that this class can be used with different types of ranges for creating sliders, levers, joysticks and more. For creating a new range please refer to ValueDescriptor where you will also find some predefined ranges.

To create a new RangeInteractable create a new child class from this, providing both a value type and compatible ValueDescriptor. You can then proceed with implementing the function UpdateValueWithGrab() to reflect the value change when the interactable is selected. Make sure to set the value via 'Value = ...'. Visual changes should ideally be done via a function call in the setter for the Value-property to reflect changes not only during a grab but every time the value of the interactable changes. We advise you to also implement the OnDrawGizmosSelected()-function to indicate how your interactor behaves. Please refer to other interactors if you need an example.

Last but not least you can create a Custom Editor for your interactable, else the ValueRangeInteractableEditor will be used.| |ValueVisualizer|An abstract base class for selecting a value from a specific range with the option to snap a value. The value as well as the behavior is described by a ValueDescriptor so that this class can be used with different types of ranges for creating sliders, levers, joysticks and more. For creating a new range please refer to the documentation of the ValueDescriptor where you will also find some predefined ranges.

The visualization but also manipulation through interaction is described by a ValueVisualizer.

ExPresS XR comes with numerous predefined customizable Visualizers and Descriptors, so be sure to check them out before you create your own. You will likely only need to create a new Visualizer as most common range-values are already implemented. Before implementing a new interactable, keep in mind, that most visualizers only implement their movement on certain local axis for simplicity. As these are local, you can of course always rotate your interactable, handle, pivot, ... to match your desired range of motion.

To implement a completely start by creating a ValueDescriptor and/or a ValueVisualizer, depending on your needs. Make sure to check out the respective documentation and that the classes are marked as [System.Serializable]. Then create a new ValueInteractable by deriving from this class, passing a type for the value, a compatible ValueDescriptor and ValueVisualizer. Continue to implement the remaining logic in your class, visualizer and descriptor. Ideally you only need to implement the abstract functions the new descriptor, so that the actual new interactable class is empty.

Note: The class also implements the interface IRangeInteractorInternal which is solely needed so that the Inspector can call functions of the generic class.| |Vector2Descriptor|A range to interpolate each individually coordinate a Vector2 between 0.0f and 1.0f (both inclusive), whilst supporting snapping.| |Vector3Descriptor|A range to interpolate each individually coordinate a Vector3 between 0.0f and 1.0f (both inclusive), whilst supporting snapping.|

Interfaces

Name Description
IRangeInteractorInternal We need this interface to call in the generic BaseComponent-Editor without knowing the exact generic type.

Namespaces

Name Description
ExPresSXR.Interaction.ValueRangeInteractable.ValueCombiner Classes for creating composite values of value range interactables, such as a Vector2 from two sliders.
ExPresSXR.Interaction.ValueRangeInteractable.ValueModifier Classes for modifying values and types of value range interactables.
⚠️ **GitHub.com Fallback** ⚠️