Skip to content

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 each update to determine whether it is in an error state; when the error state changes it marks the widget's properties as changed so the UI can react. The error flag and message are written out when the widget serializes its properties.


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 the error delegate (if provided). If the delegate result differs from the previous m_Error value, the method sets the WidgetChanges.Properties flag so downstream systems know properties changed, then updates m_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.