KROYSDOCS
HomeWhat's newv0.1.0
SCRIPTING API / UI / UIWidget

UIWidget

A widget of a UI canvas, bound by its id (C-14 retained runtime UI). Setting Text, Value or Visible updates only that widget until Play stops; the document asset is unchanged. OnClick and OnChanged fire once per frame the player clicked the widget or changed its value (slider, toggle, switch, dropdown, radio group, tab bar, stepper, input field), before the scripts' OnUpdate.

Kindclass
NamespaceKroys.EngineScripting
Members12
SourceUIWidget.cs
DECLARATION

Declaration

Namespace Kroys.EngineScripting.

Declaration
public sealed class UIWidget
REFERENCE

Members

Properties
#public Entity Canvas { get; }
Entity with the UI Canvas component.
property
#public string Id { get; }
Widget id in the UI document.
property
#public string Text { get; set; }
Label, text or hint. Reads what this script last set.
property
#public bool Visible { get; set; }
Shows or hides the widget and everything inside it.
property
#public float Value { get; set; }
Progress bar, slider, radial progress or toggle (0..1): set by the script, and updated with the value the player chose when the widget reports a change.
property
#public bool WasClicked { get; }
True on the frame after the widget was clicked or activated with Submit.
property
Fields
#public event Action? OnClick
The widget was clicked (or activated with keyboard/gamepad Submit).
field
#public event Action<float>? OnChanged
The player changed the widget: slider position, toggle/switch state (0 or 1), dropdown, radio or tab index, stepper number. Input fields report their text through OnTextChanged.
field
#public event Action<string>? OnTextChanged
Text the change carried: a confirmed input field, the chosen dropdown/radio/tab label.
field
Methods
#public bool SetBackground(Color color)
Replaces the widget's background colour.
method
#public bool SetOffset(float x, float y)
Moves the widget from its anchor, in the document's reference pixels.
method
#public bool TryGetChange(out float changedValue, out string changedText)
The value and text the widget reported this frame, when it changed.
method
Signatures
public Entity Canvas { get; }
public string Id { get; }
public string Text { get; set; }
public bool Visible { get; set; }
public float Value { get; set; }
public bool SetBackground(Color color)
public bool SetOffset(float x, float y)
public bool WasClicked { get; }
public bool TryGetChange(out float changedValue, out string changedText)
public event Action? OnClick
public event Action<float>? OnChanged
public event Action<string>? OnTextChanged

KroysEngine 0.1.0 documentation, built from the engine repository by Tools/BuildDocsSite.py.