Game.UI.Editor.StringInputFieldWithError
Assembly: Game
Namespace: Game.UI.Editor
Type: public class
Base: StringInputField
Summary:
A text input widget that extends StringInputField with an optional runtime error state and an associated localized error message. The control evaluates a user-provided Func
Fields
private bool m_Error
Holds the current computed error state (true when the input is considered in error). This value is updated during Update().
Properties
-
public Func<bool> error { get; set; }
A delegate that, when set, will be invoked during Update() to determine whether the input is currently in an error condition. The delegate should return true to indicate an error. -
public LocalizedString errorMessage { get; set; }
A localized message describing the error to display or serialize when the control is in an error state.
Constructors
public StringInputFieldWithError()
Default constructor (compiler-generated). Initializes a new instance of the control. No special construction logic is defined in source.
Methods
-
protected override WidgetChanges Update()
Overrides the base Update to evaluate theerror
delegate (if provided). If the delegate result differs from the previousm_Error
value, the method sets the WidgetChanges.Properties flag so downstream systems know properties changed, then updatesm_Error
. Finally it returns the accumulated WidgetChanges (including any changes reported by base.Update()). -
protected override void WriteProperties(IJsonWriter writer)
Overrides property serialization to include the error state and error message. Calls base.WriteProperties(writer) first, then writes an "error" boolean property (the current m_Error) and an "errorMessage" property (the LocalizedString).
Usage Example
// Create the input field and configure error detection and message.
var input = new StringInputFieldWithError();
// Example: mark as error when the input is empty
input.error = () => string.IsNullOrWhiteSpace(input.text);
// Assign a localized error message (construct according to your LocalizedString API)
input.errorMessage = new LocalizedString("UI_Error_InputRequired");
// The control will evaluate input.error each update and set its error state accordingly.
// When the error state changes, the widget will mark its properties as changed and
// WriteProperties will include "error" and "errorMessage" in JSON output.