Class NumericalField<TValue>
Numerical Field UI element.
Inheritance
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
public abstract class NumericalField<TValue> : ExVisualElement, IEventHandler, IVisualElementScheduler, IExperimentalFeatures, ITransitionAnimations, ITransform, IResolvedStyle, IContextOverrideElement, IAdditionalDataHolder, IInputElement<TValue>, IValidatableElement<TValue>, ISizeableElement, INotifyValueChanging<TValue>, INotifyValueChanged<TValue>, IFormattable<TValue> where TValue : struct, IComparable, IComparable<TValue>, IFormattable
Type Parameters
Name | Description |
---|---|
TValue | 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 |
---|---|
Visual |
m_InputElement
The input element.
Declaration
protected readonly TextField m_InputElement
Field Value
Type | Description |
---|---|
Text |
m_LastValue
The last value of the element set during Set
Declaration
protected TValue m_LastValue
Field Value
Type | Description |
---|---|
TValue |
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 |
---|---|
Visual |
m_UnitElement
The unit element.
Declaration
protected readonly LocalizedTextElement m_UnitElement
Field Value
Type | Description |
---|---|
Localized |
m_Value
The value of the element.
Declaration
protected TValue m_Value
Field Value
Type | Description |
---|---|
TValue |
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 |
---|---|
Visual |
Overrides
formatFunction
The format function of the element.
Declaration
public FormatFunction<TValue> formatFunction { get; set; }
Property Value
Type | Description |
---|---|
Format |
formatString
The format string of the element.
Declaration
public string formatString { get; set; }
Property Value
Type | Description |
---|---|
string |
highValue
Maximum value.
Declaration
public Optional<TValue> highValue { get; set; }
Property Value
Type | Description |
---|---|
Optional<TValue> |
invalid
The invalid state of the element.
Declaration
public bool invalid { get; set; }
Property Value
Type | Description |
---|---|
bool |
lowValue
Minimum value.
Declaration
public Optional<TValue> lowValue { get; set; }
Property Value
Type | Description |
---|---|
Optional<TValue> |
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<TValue, bool> validateValue { get; set; }
Property Value
value
The value of the element.
Declaration
public TValue value { get; set; }
Property Value
Type | Description |
---|---|
TValue |
Methods
AreEqual(TValue, TValue)
Check if two values of type TValue
are equal.
Declaration
protected abstract bool AreEqual(TValue a, TValue b)
Parameters
Type | Name | Description |
---|---|---|
TValue | a | The first value to test. |
TValue | b | The second value to test. |
Returns
Type | Description |
---|---|
bool | True if both values are considered equals, false otherwise. |
GetIncrementFactor(TValue)
Calculate the increment factor based on a base value.
Declaration
protected abstract float GetIncrementFactor(TValue baseValue)
Parameters
Type | Name | Description |
---|---|---|
TValue | 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(TValue, float)
Increment a given value with a given delta.
Declaration
protected abstract TValue Increment(TValue originalValue, float delta)
Parameters
Type | Name | Description |
---|---|---|
TValue | originalValue | The original value. |
float | delta | The delta used for increment. |
Returns
Type | Description |
---|---|
TValue | The incremented value. |
Max(TValue, TValue)
Return the biggest value between a and b.
Declaration
protected abstract TValue Max(TValue a, TValue b)
Parameters
Type | Name | Description |
---|---|---|
TValue | a | The first value to test. |
TValue | b | The second value to test. |
Returns
Type | Description |
---|---|
TValue | The biggest value. |
Min(TValue, TValue)
Return the smallest value between a and b.
Declaration
protected abstract TValue Min(TValue a, TValue b)
Parameters
Type | Name | Description |
---|---|---|
TValue | a | The first value to test. |
TValue | b | The second value to test. |
Returns
Type | Description |
---|---|
TValue | The smallest value. |
ParseRawValueToString(TValue)
Define the conversion from a TValue
value to a string value.
Declaration
protected abstract string ParseRawValueToString(TValue val)
Parameters
Type | Name | Description |
---|---|---|
TValue | 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 TValue)
Define the conversion from the string value to a TValue
value.
Declaration
protected abstract bool ParseStringToValue(string strValue, out TValue val)
Parameters
Type | Name | Description |
---|---|---|
string | strValue | The string value to convert. |
TValue | val | The |
Returns
Type | Description |
---|---|
bool | True if the conversion is possible, False otherwise. |
ParseValueToString(TValue)
Define the conversion from a TValue
value to a string value.
Declaration
protected abstract string ParseValueToString(TValue val)
Parameters
Type | Name | Description |
---|---|---|
TValue | val | The |
Returns
Type | Description |
---|---|
string | The converted value. |
SetValueWithoutNotify(TValue)
Set the value of the element without notifying the change.
Declaration
public void SetValueWithoutNotify(TValue newValue)
Parameters
Type | Name | Description |
---|---|---|
TValue | newValue | The new value of the element. |