Game.UI.Widgets.ValueField
Assembly:
Assembly-CSharp (game code)
Namespace:
Game.UI.Widgets
Type:
class
Base:
ReadonlyField
Summary:
A small UI widget class that exposes a string value and ensures callers never receive a null string. It overrides GetValue() to return an empty string when the base implementation returns null — useful for avoiding null checks in UI code and bindings.
Fields
- None.
This class declares no private or public fields of its own; it relies on members inherited from ReadonlyField.
Properties
- None declared on this class.
Any properties are inherited from ReadonlyField(not shown here). This class only customizes behavior by overriding a method.
Constructors
public ValueField()
(implicit)
No explicit constructors are declared; the compiler-provided parameterless constructor is used. Initialization behavior (if any) is handled by base classes.
Methods
public override string GetValue()
Overrides the base ReadonlyField.GetValue() to ensure a non-null return. If base.GetValue() returns null, this implementation returns string.Empty instead. This avoids propagating null strings to callers and simplifies UI code that expects a string.
Usage Example
// Create or obtain the ValueField instance (how it's created depends on UI framework)
var valueField = new Game.UI.Widgets.ValueField();
// Retrieve the value safely without needing a null check
string value = valueField.GetValue(); // Always non-null; "" if underlying value was null