valuedescriptor - eisclimber/ExPresS-XR GitHub Wiki
Class in ExPresSXR.Interaction.ValueRangeInteractable
Inherits from System.Object
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
public abstract class ValueDescriptor<V>| Name | Description |
|---|---|
| V | Class used to interpolate between. |
| Name | Description |
|---|---|
| OnMaxValue | Emitted when the value is changed to a max value. |
Be careful when using this event without snapping enabled as can get called multiple times while grabbing.
A threshold value modified (i.e. Float01ThresholdModifier ) might be more appropriate in these cases.|
|OnMinValue|Emitted when the value is changed to a min value.
Be careful when using this event without snapping enabled as can get called multiple times while grabbing.
A threshold value modified (i.e. Float01ThresholdModifier ) might be more appropriate in these cases.|
|OnSnapped|Emitted when a value is snapped.|
|OnValueChanged|Emitted when a value changed. Provides the new and old value respectively.|
| Name | Description |
|---|---|
| IsMaxValue() | Checks if the current value is considered minimal. |
| IsMaxValue(V) | Checks if the provided value is considered maximal. |
| IsMinValue() | Checks if the current value is considered minimal. |
| IsMinValue(V) | Checks if the provided value is considered minimal. |
| IsValueSnappingEnabled() | Allows checking if snapping is enabled and is used internally to emit the correct events. |
| This function must be implemented as snapping must be implemented individually. If no snapping will be performed, simply return false. | |
| ResetValue() | Resets the value to it's default. |
| Name | Description |
|---|---|
| DefaultMaxValue | Accessor defining the default max value. |
| There can be multiple max values, but this is the one used in the editor for setting the value. | |
| Make sure it evaluates to a valid max value according to IsMaxValue(V) . | |
| DefaultMinValue | Accessor defining the default min value. |
| There can be multiple min values, but this is the one used in the editor for setting the value. | |
| Make sure it evaluates to a valid min value according to IsMinValue(V) . | |
| Value | Property for getting and setting the value. If you do not need to add custom attributes (like [Range(..)]) to your value field, |
you can use BaseValueDescriptor , which has the property already set up. |
|
Otherwise you'll need to implement it yourself, making sure to call the same functions as in BaseValueDescriptor , |
|
| to ensure a correct behavior. |