Skip to content

Game.UI.Widgets.Group

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

Type: class

Base: NamedWidgetWithTooltip, IContainerWidget

Summary:
A container widget that holds a list of child IWidget instances and provides a tooltip-positioning option. The class exposes a nested TooltipPosition enum to select whether the tooltip should be shown on the group's title or the container area. When the children list is replaced, defaults are applied to the new children via ContainerExtensions.SetDefaults(...) and the group is notified of the change by calling SetChildrenChanged() (inherited behavior).


Fields

  • private IList<IWidget> m_Children
    Holds the current list of child widgets. Initialized to Array.Empty() by default to avoid null references.

Nested types

  • public enum TooltipPosition { Title, Container }
    Determines where the tooltip should be displayed:
  • Title — tooltip associated with the group's title element.
  • Container — tooltip associated with the container area (default).

Properties

  • public TooltipPosition tooltipPos { get; set; }
    Controls where the group's tooltip will be displayed. Default value is TooltipPosition.Container. This property is serialized as an integer by WriteProperties.

  • public IList<IWidget> children
    Get or set the group's children. The setter:

  • Returns early if the same instance is assigned.
  • Calls ContainerExtensions.SetDefaults(value) to apply default settings to the new children collection.
  • Updates the backing field and calls SetChildrenChanged() to notify the widget system of the update.

  • public override IList<IWidget> visibleChildren => children
    The visible children are the same as the children collection. Overrides the base implementation to expose this group's children as visible children.

Constructors

  • public Group()
    No explicit constructor is declared in source; the class relies on the default parameterless constructor. The m_Children field is initialized inline to Array.Empty() and tooltipPos defaults to TooltipPosition.Container.

Methods

  • protected override void WriteProperties(IJsonWriter writer)
    Serializes the widget's properties to JSON:
  • Calls base.WriteProperties(writer) to serialize inherited properties.
  • Writes a property named "tooltipPos" with the integer value of tooltipPos (writer.Write((int)tooltipPos)). This ensures the tooltip position choice is persisted.

Usage Example

// Create a group, set tooltip position, and assign children.
var group = new Game.UI.Widgets.Group();
group.tooltipPos = Game.UI.Widgets.Group.TooltipPosition.Title;

// Example child widgets (IWidget implementations)
IWidget child1 = new SomeWidget { name = "Child1" };
IWidget child2 = new SomeWidget { name = "Child2" };

// Assign children: ContainerExtensions.SetDefaults will be called automatically,
// and the group will be notified via SetChildrenChanged().
group.children = new List<IWidget> { child1, child2 };

// The group's visibleChildren will reflect the same list:
var visible = group.visibleChildren;

Notes: - ContainerExtensions.SetDefaults(...) and SetChildrenChanged() are part of the widget/container infrastructure and enforce standard defaults and refresh behavior when children change. - WriteProperties expects an IJsonWriter to serialize the widget; the tooltip position is stored as an integer to keep compatibility with the existing serialization format.