Class BaseSlider<TValueType>
Base class for any Slider (TouchSliderFloat, TouchSliderInt, SliderFloat, SliderInt).
Inheritance
Inherited Members
Namespace: UnityEngine.Dt.App.UI
Syntax
public abstract class BaseSlider<TValueType> : ExVisualElement, IEventHandler, IStylePropertyAnimations, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IResolvedStyle, IValidatableElement<TValueType>, INotifyValueChanging<TValueType>, INotifyValueChanged<TValueType> where TValueType : IEquatable<TValueType>
Type Parameters
Name | Description |
---|---|
TValueType | A comparable value type. |
Constructors
BaseSlider()
Default constructor.
Declaration
protected BaseSlider()
Fields
m_DraggerManipulator
The dragger manipulator used to move the slider.
Declaration
protected Draggable m_DraggerManipulator
Field Value
Type | Description |
---|---|
Draggable |
m_HighValue
Slider max value.
Declaration
protected TValueType m_HighValue
Field Value
Type | Description |
---|---|
TValueType |
m_LowValue
Slider min value.
Declaration
protected TValueType m_LowValue
Field Value
Type | Description |
---|---|
TValueType |
m_PreviousValue
The previous value of the slider before the user started interacting with it.
Declaration
protected TValueType m_PreviousValue
Field Value
Type | Description |
---|---|
TValueType |
m_Value
The current value of the slider.
Declaration
protected TValueType m_Value
Field Value
Type | Description |
---|---|
TValueType |
Properties
formatString
The format string used to display the value of the slider.
Declaration
public string formatString { get; set; }
Property Value
Type | Description |
---|---|
String |
highValue
Specify the maximum value in the range of this slider.
Declaration
public TValueType highValue { get; set; }
Property Value
Type | Description |
---|---|
TValueType |
invalid
The invalid state of the slider.
Declaration
public bool invalid { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
lowValue
Specify the minimum value in the range of this slider.
Declaration
public TValueType lowValue { get; set; }
Property Value
Type | Description |
---|---|
TValueType |
validateValue
The validation function used to validate the value of the slider.
Declaration
public Func<TValueType, bool> validateValue { get; set; }
Property Value
Type | Description |
---|---|
Func<TValueType, Boolean> |
Implements
value
The current value of the slider.
Declaration
public TValueType value { get; set; }
Property Value
Type | Description |
---|---|
TValueType |
Implements
Methods
Clamp(TValueType, TValueType, TValueType)
Utility method to clamp a TValueType
value between specified bounds.
Declaration
protected virtual TValueType Clamp(TValueType v, TValueType lowBound, TValueType highBound)
Parameters
Type | Name | Description |
---|---|---|
TValueType | v | The value to clamp. |
TValueType | lowBound | Minimum |
TValueType | highBound | Maximum |
Returns
Type | Description |
---|---|
TValueType | The clamped value. |
ClampValue()
Called when the low or high value has changed and needs to check if the current value fits in this new range.
Declaration
protected virtual void ClampValue()
ComputeValueDraggerPosition(Single, Single)
Returns the value to set as slider value based on a given dragger position.
Declaration
protected virtual TValueType ComputeValueDraggerPosition(float sliderLength, float dragElementPos)
Parameters
Type | Name | Description |
---|---|---|
Single | sliderLength | The length of the slider. |
Single | dragElementPos | The position of the dragger. |
Returns
Type | Description |
---|---|
TValueType | The value to set as slider value based on a given dragger position. |
Decrement(TValueType)
Method to implement which returns the decrement of a given value.
Declaration
protected abstract TValueType Decrement(TValueType val)
Parameters
Type | Name | Description |
---|---|---|
TValueType | val | The value to decrement. |
Returns
Type | Description |
---|---|
TValueType | The decremented value. |
GetClampedValue(TValueType)
Return the clamped value using current lowValue and highValue values.
Declaration
protected virtual TValueType GetClampedValue(TValueType newValue)
Parameters
Type | Name | Description |
---|---|---|
TValueType | newValue | The value to clamp. |
Returns
Type | Description |
---|---|
TValueType |
GetSliderRect()
Returns the rect of the interactive part of the slider.
Declaration
protected virtual Rect GetSliderRect()
Returns
Type | Description |
---|---|
Rect | The rect of the interactive part of the slider. |
Increment(TValueType)
Method to implement which returns the increment of a given value.
Declaration
protected abstract TValueType Increment(TValueType val)
Parameters
Type | Name | Description |
---|---|---|
TValueType | val | The value to increment. |
Returns
Type | Description |
---|---|
TValueType | The incremented value. |
OnGeometryChanged(GeometryChangedEvent)
Event callback called when the geometry of the slider has changed in the layout.
Declaration
protected virtual void OnGeometryChanged(GeometryChangedEvent evt)
Parameters
Type | Name | Description |
---|---|---|
GeometryChangedEvent | evt | The geometry changed event. |
OnSliderRangeChanged()
Called when the low or high value of Slider has changed.
Declaration
protected virtual void OnSliderRangeChanged()
OnTrackClicked()
Called when the track has received a click event.
Declaration
protected virtual void OnTrackClicked()
OnTrackDown(Draggable)
Event callback called when a pointer down event is received.
Declaration
protected virtual void OnTrackDown(Draggable dragger)
Parameters
Type | Name | Description |
---|---|---|
Draggable | dragger | The dragger manipulator. |
OnTrackDragged(Draggable)
Event callback called when the dragger is dragged.
Declaration
protected virtual void OnTrackDragged(Draggable dragger)
Parameters
Type | Name | Description |
---|---|---|
Draggable | dragger | The dragger manipulator. |
OnTrackUp(Draggable)
Event callback called when a pointer up event is received.
Declaration
protected virtual void OnTrackUp(Draggable dragger)
Parameters
Type | Name | Description |
---|---|---|
Draggable | dragger | The dragger manipulator. |
ParseStringToValue(String, out TValueType)
Method to implement to resolve a String value into a TValueType
value.
You can use TryParse(String, Single) for floating point value types for example.
Declaration
protected abstract bool ParseStringToValue(string strValue, out TValueType value)
Parameters
Type | Name | Description |
---|---|---|
String | strValue | The String value to convert. |
TValueType | value | The StringThe converted value. |
Returns
Type | Description |
---|---|
Boolean | True if can be parsed, False otherwise. |
ParseValueToString(TValueType)
Method to implement to resolve a TValueType
value into a String value.
You can use ToString() for floating point value types for example.
You can also round the value if you want a specific number of decimals.
Declaration
protected virtual string ParseValueToString(TValueType val)
Parameters
Type | Name | Description |
---|---|---|
TValueType | val | The |
Returns
Type | Description |
---|---|
String |
SetValueFromDrag(Single)
Custom implementation of the slider value from the drag position.
Declaration
protected virtual void SetValueFromDrag(float newPos)
Parameters
Type | Name | Description |
---|---|---|
Single | newPos | The new position of the dragger. |
SetValueWithoutNotify(TValueType)
Set the value of the slider without sending any event.
Declaration
public abstract void SetValueWithoutNotify(TValueType newValue)
Parameters
Type | Name | Description |
---|---|---|
TValueType | newValue | The new value of the slider. |
Implements
SliderLerpUnclamped(TValueType, TValueType, Single)
Method to implement which returns a value based on the linear interpolation of a given interpolant between a specific range.
Usually you can use directly LerpUnclamped for floating point value types.
Declaration
protected abstract TValueType SliderLerpUnclamped(TValueType a, TValueType b, float interpolant)
Parameters
Type | Name | Description |
---|---|---|
TValueType | a | The lowest value in the range. |
TValueType | b | The highest value in the range. |
Single | interpolant | The normalized value to process. |
Returns
Type | Description |
---|---|
TValueType |
SliderNormalizeValue(TValueType, TValueType, TValueType)
Method to implement which returns the normalized value of a given value in a specific range.
Usually you can use directly an InverseLerp for floating point value types.
Declaration
protected abstract float SliderNormalizeValue(TValueType currentValue, TValueType lowerValue, TValueType higherValue)
Parameters
Type | Name | Description |
---|---|---|
TValueType | currentValue | The value to normalize. |
TValueType | lowerValue | The lowest value in the range. |
TValueType | higherValue | The highest value in the range. |
Returns
Type | Description |
---|---|
Single |