Skip to content

Game.UI.Debug.IntInputField

Assembly: Assembly-CSharp (game runtime)
Namespace: Game.UI.Debug

Type: class

Base: Game.UI.Widgets.IntInputField

Summary:
A lightweight wrapper that adapts a debug-mode string input widget (Game.Debug.IntInputField) to the int-based UI widget API (Game.UI.Widgets.IntInputField). It polls the underlying debug widget for its string value, caches it, parses it to an integer, and exposes the parsed value via the widget API. Useful when the debug UI provides values as strings but the game UI or systems expect integer input.


Fields

  • private Game.Debug.IntInputField m_DebugWidget
    Holds the reference to the underlying debug-mode input widget that produces/accepts string values. This is the source/target for string-based value reads/writes.

  • private string m_StringValue
    Cached copy of the last-read string value from the debug widget. Used to detect changes before attempting to re-parse.

  • private int m_IntValue
    Cached parsed integer value parsed from m_StringValue. This value is returned by GetValue().

Properties

  • public override string propertiesTypeName { get; }
    Returns the FullName of the base widget type (typeof(Game.UI.Widgets.IntInputField).FullName). This is used to identify the properties type associated with the base widget (for property mapping/serialization or editor tooling). It is a read-only override implemented as an expression-bodied property.

Constructors

  • public IntInputField(Game.Debug.IntInputField debugWidget)
    Creates a new wrapper instance that bridges the provided debug widget to the int-based widget API. The debugWidget parameter is stored in m_DebugWidget. No additional initialization is performed.

Methods

  • protected override WidgetChanges Update()
    Polls the underlying debug widget for its current string value via m_DebugWidget.GetValue(). If the string differs from the cached m_StringValue, the cache is updated and int.TryParse is called to parse the new string into m_IntValue. Note: on parse failure m_IntValue becomes 0 (int.TryParse sets the out parameter to 0 and returns false). After handling the value change, the method forwards to base.Update() and returns its WidgetChanges result. This method is used to keep the wrapper's cached values in sync with the debug widget.

  • public override int GetValue()
    Returns the last parsed integer value (m_IntValue). This is what consumers of the int-based widget API should use.

  • public override void SetValue(int value)
    Writes an integer value back to the underlying debug widget by converting the integer to a string and calling m_DebugWidget.SetValue(value.ToString()). This keeps the debug widget display in sync when the value is changed programmatically.

Usage Example

// Assume you have an instance of the debug widget from the debug UI:
Game.Debug.IntInputField debugWidget = /* obtain from debug UI system */;

// Wrap it to use the int-based widget API:
var wrapper = new Game.UI.Debug.IntInputField(debugWidget);

// In your update loop / UI update:
wrapper.Update();               // polls and parses the debug widget value
int current = wrapper.GetValue(); // read parsed integer

// Set a new value (updates debug widget string representation):
wrapper.SetValue(123);

Notes: - When the debug widget's value is not a valid integer string, m_IntValue will be set to 0 due to int.TryParse behavior. - The wrapper relies on polling via Update(); it only re-parses when the string changes.