Skip to content

Game.UI.Widgets.IWarning

Assembly:
Assembly-CSharp (typical for Cities: Skylines 2 mods; confirm with your project if different)

Namespace:
Game.UI.Widgets

Type:
public interface

Base:
None (no inherited interfaces)

Summary:
IWarning is a minimal UI contract used by widgets to expose a boolean warning state. Implementing types provide get/set access to the warning flag so UI systems or other components can query or change whether the widget is in a "warning" condition (for example to show a warning icon, change styling, or trigger alerts).


Fields

  • This interface defines no fields. Implementations may have backing fields to store the state.

Properties

  • public bool warning { get; set; }
    Represents the warning state of the widget. Implementors should ensure that setting this property updates the visual state or behavior of the widget as appropriate (e.g., show/hide warning indicators, change colors). Consider raising change notifications or calling update/redraw logic when the property is changed so bound UI systems can react.

Constructors

  • Interfaces do not define constructors. Implementations must provide their own constructors.

Methods

  • The interface declares no explicit methods beyond the property accessors. Any logic for reacting to warning state changes must be implemented by the concrete class.

Usage Example

// Example implementation of IWarning in a widget class
public class ExampleWidget : MonoBehaviour, Game.UI.Widgets.IWarning
{
    private bool _warning;

    public bool warning
    {
        get => _warning;
        set
        {
            if (_warning == value) return;
            _warning = value;
            UpdateWarningVisuals();
        }
    }

    private void UpdateWarningVisuals()
    {
        // Show or hide a warning icon, change colors, etc.
        // e.g. warningIcon.SetActive(_warning);
    }
}

// Example usage elsewhere
var widget = someGameObject.GetComponent<ExampleWidget>();
widget.warning = true; // triggers the widget to show warning visuals

Notes and recommendations: - If the UI framework in use supports data binding or notifications, consider raising an event or using the framework's binding hooks when the property changes to ensure the UI updates efficiently. - Keep the property side-effect behavior (visual updates) light-weight to avoid performance issues if it is toggled frequently. - If the warning state must be serialized (saved/loaded), handle that in the implementing class (interfaces cannot carry serialization behavior).