Game.UI.Editor.ErrorLabel
Assembly:
Namespace: Game.UI.Editor
Type: class
Base: Game.UI.Widgets.Label
Summary:
A simple UI label that exposes a serializable visibility flag. ErrorLabel wraps an internal boolean field (m_Visible) and provides a public property (visible) that triggers property-change notification when toggled. The visibility value is written to an IJsonWriter during property serialization so the UI framework can persist or transmit the state.
Fields
private bool m_Visible
Backing field for the public visible property. Tracks the label's intended visibility state and is serialized by WriteProperties.
Properties
public bool visible { get; set; }
Public property exposing m_Visible. Setting this property updates the backing field and calls SetPropertiesChanged() when the value actually changes, which notifies the UI system that the component's properties need to be re-evaluated or re-rendered.
Constructors
public ErrorLabel()
Compiler-provided default constructor. No explicit constructor is declared in the source; the default initialization leaves m_Visible false.
Methods
protected override void WriteProperties(IJsonWriter writer) : System.Void
Overrides the base Label.WriteProperties to include the visible property in the serialized output. Implementation calls base.WriteProperties(writer) and then writes the "visible" property name followed by the current m_Visible value:- writer.PropertyName("visible");
- writer.Write(m_Visible); This ensures the visibility flag is included when the UI framework serializes the widget's properties.
Usage Example
// Create an ErrorLabel and toggle visibility
var errorLabel = new ErrorLabel();
// Show the label and notify the UI system of the change
errorLabel.visible = true;
// Serialize properties (IJsonWriter instance provided by UI framework)
IJsonWriter writer = /* obtain writer from context */;
errorLabel.WriteProperties(writer);
Notes: - The class depends on Colossal.UI.Binding.IJsonWriter for serialization and on the base Label type (Game.UI.Widgets.Label) for core label behavior. - Calling SetPropertiesChanged() inside the setter ensures the UI system will react only when the visibility actually changes.