Class NumericalField<TValueType>
Numerical Field UI element.
Inheritance
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
public abstract class NumericalField<TValueType> : ExVisualElement, IEventHandler, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IResolvedStyle, IContextOverrideElement, IAdditionalDataHolder, IInputElement<TValueType>, IValidatableElement<TValueType>, ISizeableElement, INotifyValueChanging<TValueType>, INotifyValueChanged<TValueType> where TValueType : struct, IComparable, IComparable<TValueType>, IFormattable
Type Parameters
Name | Description |
---|---|
TValueType | The type of the numerical value. |
Constructors
NumericalField()
Default constructor.
Declaration
protected NumericalField()
Fields
inputContainerUssClassName
The NumericalField input container styling class.
Declaration
public const string inputContainerUssClassName = "appui-numericalfield__inputcontainer"
Field Value
Type | Description |
---|---|
string |
inputUssClassName
The NumericalField input styling class.
Declaration
public const string inputUssClassName = "appui-numericalfield__input"
Field Value
Type | Description |
---|---|
string |
m_InputContainer
The input container.
Declaration
protected readonly VisualElement m_InputContainer
Field Value
Type | Description |
---|---|
VisualElement |
m_InputElement
The input element.
Declaration
protected readonly TextField m_InputElement
Field Value
Type | Description |
---|---|
TextField |
m_LastValue
The last value of the element set during SetValueWithoutNotify(TValueType).
Declaration
protected TValueType m_LastValue
Field Value
Type | Description |
---|---|
TValueType |
m_Size
The size of the element.
Declaration
protected Size m_Size
Field Value
Type | Description |
---|---|
Size |
m_TrailingContainer
The trailing container.
Declaration
protected readonly VisualElement m_TrailingContainer
Field Value
Type | Description |
---|---|
VisualElement |
m_UnitElement
The unit element.
Declaration
protected readonly LocalizedTextElement m_UnitElement
Field Value
Type | Description |
---|---|
LocalizedTextElement |
m_Value
The value of the element.
Declaration
protected TValueType m_Value
Field Value
Type | Description |
---|---|
TValueType |
sizeUssClassName
The NumericalField size styling class.
Declaration
public const string sizeUssClassName = "appui-numericalfield--size-"
Field Value
Type | Description |
---|---|
string |
trailingContainerUssClassName
The NumericalField trailing container styling class.
Declaration
public const string trailingContainerUssClassName = "appui-numericalfield__trailingcontainer"
Field Value
Type | Description |
---|---|
string |
unitUssClassName
The NumericalField unit styling class.
Declaration
public const string unitUssClassName = "appui-numericalfield__unit"
Field Value
Type | Description |
---|---|
string |
ussClassName
The NumericalField main styling class.
Declaration
public const string ussClassName = "appui-numericalfield"
Field Value
Type | Description |
---|---|
string |
Properties
contentContainer
The content container of the element.
Declaration
public override VisualElement contentContainer { get; }
Property Value
Type | Description |
---|---|
VisualElement |
Overrides
formatString
The format string of the element.
Declaration
public string formatString { get; set; }
Property Value
Type | Description |
---|---|
string |
highValue
Maximum value.
Declaration
public Optional<TValueType> highValue { get; set; }
Property Value
Type | Description |
---|---|
Optional<TValueType> |
invalid
The invalid state of the element.
Declaration
public bool invalid { get; set; }
Property Value
Type | Description |
---|---|
bool |
lowValue
Minimum value.
Declaration
public Optional<TValueType> lowValue { get; set; }
Property Value
Type | Description |
---|---|
Optional<TValueType> |
size
The size of the element.
Declaration
public Size size { get; set; }
Property Value
Type | Description |
---|---|
Size |
unit
The unit of the element.
Declaration
public string unit { get; set; }
Property Value
Type | Description |
---|---|
string |
validateValue
Method to validate the value.
Declaration
public Func<TValueType, bool> validateValue { get; set; }
Property Value
Type | Description |
---|---|
Func<TValueType, bool> |
value
The value of the element.
Declaration
public TValueType value { get; set; }
Property Value
Type | Description |
---|---|
TValueType |
Methods
AreEqual(TValueType, TValueType)
Check if two values of type TValueType
are equal.
Declaration
protected abstract bool AreEqual(TValueType a, TValueType b)
Parameters
Type | Name | Description |
---|---|---|
TValueType | a | The first value to test. |
TValueType | b | The second value to test. |
Returns
Type | Description |
---|---|
bool | True if both values are considered equals, false otherwise. |
GetIncrementFactor(TValueType)
Calculate the increment factor based on a base value.
Declaration
protected abstract float GetIncrementFactor(TValueType baseValue)
Parameters
Type | Name | Description |
---|---|---|
TValueType | baseValue | The base value. |
Returns
Type | Description |
---|---|
float | The increment factor. |
GetSizeUssClassName(Size)
Declaration
public static string GetSizeUssClassName(Size enumValue)
Parameters
Type | Name | Description |
---|---|---|
Size | enumValue |
Returns
Type | Description |
---|---|
string |
Increment(TValueType, float)
Increment a given value with a given delta.
Declaration
protected abstract TValueType Increment(TValueType originalValue, float delta)
Parameters
Type | Name | Description |
---|---|---|
TValueType | originalValue | The original value. |
float | delta | The delta used for increment. |
Returns
Type | Description |
---|---|
TValueType | The incremented value. |
Max(TValueType, TValueType)
Return the biggest value between a and b.
Declaration
protected abstract TValueType Max(TValueType a, TValueType b)
Parameters
Type | Name | Description |
---|---|---|
TValueType | a | The first value to test. |
TValueType | b | The second value to test. |
Returns
Type | Description |
---|---|
TValueType | The biggest value. |
Min(TValueType, TValueType)
Return the smallest value between a and b.
Declaration
protected abstract TValueType Min(TValueType a, TValueType b)
Parameters
Type | Name | Description |
---|---|---|
TValueType | a | The first value to test. |
TValueType | b | The second value to test. |
Returns
Type | Description |
---|---|
TValueType | The smallest value. |
ParseRawValueToString(TValueType)
Define the conversion from a TValueType
value to a string value.
Declaration
protected abstract string ParseRawValueToString(TValueType val)
Parameters
Type | Name | Description |
---|---|---|
TValueType | val | The |
Returns
Type | Description |
---|---|
string | The converted value. |
Remarks
This method is used to convert the value to a string without any formatting.
ParseStringToValue(string, out TValueType)
Define the conversion from the string value to a TValueType
value.
Declaration
protected abstract bool ParseStringToValue(string strValue, out TValueType val)
Parameters
Type | Name | Description |
---|---|---|
string | strValue | The string value to convert. |
TValueType | val | The |
Returns
Type | Description |
---|---|
bool | True if the conversion is possible, False otherwise. |
ParseValueToString(TValueType)
Define the conversion from a TValueType
value to a string value.
Declaration
protected abstract string ParseValueToString(TValueType val)
Parameters
Type | Name | Description |
---|---|---|
TValueType | val | The |
Returns
Type | Description |
---|---|
string | The converted value. |
SetValueWithoutNotify(TValueType)
Set the value of the element without notifying the change.
Declaration
public void SetValueWithoutNotify(TValueType newValue)
Parameters
Type | Name | Description |
---|---|---|
TValueType | newValue | The new value of the element. |