Skip to content

Game.UI.Widgets.MultilineText

Assembly: Assembly-CSharp
Namespace: Game.UI.Widgets

Type: class

Base: NamedWidget

Summary:
MultilineText is a simple UI widget representing a named, multi-line text element that can optionally carry an icon identifier. It extends NamedWidget and customizes serialization of widget properties by overriding WriteProperties to include an "icon" field in the JSON writer used by the UI system (Colossal.UI.Binding.IJsonWriter). This class is intended for use within the game's UI layout/serialization pipeline (e.g., when saving or exporting widget definitions).


Fields

  • This class declares no explicit fields. All state is exposed via properties or inherited from NamedWidget.
    {{ Additional info: there are no private backing fields in this class; serialization is implemented directly via the WriteProperties override. }}

Properties

  • public string icon { get; set; }
    This property holds the icon identifier (for example, an atlas/key or path used by the UI skin). When the widget is serialized via WriteProperties, this value is written under the "icon" property name. If null or empty, the write call will still be invoked; behavior when null depends on the IJsonWriter implementation (it may emit null or omit the property value depending on the writer).

Constructors

  • public MultilineText()
    The class does not declare an explicit constructor, so the default parameterless constructor is used. Use this to create a new instance and then set properties (name, icon, etc.) before the widget is serialized or added to the UI hierarchy.

Methods

  • protected override void WriteProperties(IJsonWriter writer) : System.Void
    Overrides the base NamedWidget.WriteProperties to append the "icon" property to the JSON writer. Implementation sequence:
  • Calls base.WriteProperties(writer) to let the base class write its properties.
  • Calls writer.PropertyName("icon") followed by writer.Write(icon) to emit the icon property.

This method is invoked by the UI serialization pipeline; do not call it directly unless you are implementing custom serialization logic. Keep in mind writer behavior for null/empty strings depends on the IJsonWriter implementation in Colossal.UI.Binding.

Usage Example

// Create and configure the widget
var multi = new Game.UI.Widgets.MultilineText
{
    name = "description",
    icon = "Icons/Info" // icon id/path used by your UI skin or atlas
};

// The UI serialization system will call WriteProperties(writer) when exporting or saving the widget,
// producing a JSON object that includes an "icon" property with the value "Icons/Info".