Skip to content

Game.UI.Tooltip.TooltipGroup

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

Type: public class TooltipGroup

Base: Widget

Summary:
TooltipGroup is a UI widget used to group and lay out tooltip-related child widgets. It stores a 2D position (Unity.Mathematics.float2), horizontal and vertical alignment settings, and a Category flag. The class manages a public children collection (IList) and tracks the last applied children (m_LastChildren) so it can detect changes and apply defaults via ContainerExtensions.SetDefaults when children are updated. It also serializes position, alignments and category into an IJsonWriter in WriteProperties.


Fields

  • private Unity.Mathematics.float2 m_Position
    Holds the group's local position (x,y). Backing field for the public position property.

  • private Category m_Category
    Backing field for the category flags (enum Category). Used to mark the tooltip group with one or more categories.

  • private Alignment m_HorizontalAlignment
    Backing field for horizontal alignment (Start, Center, End). Used by layout/serialization.

  • private Alignment m_VerticalAlignment
    Backing field for vertical alignment (Start, Center, End). Used by layout/serialization.

  • private System.Collections.Generic.List<IWidget> m_LastChildren = new System.Collections.Generic.List<IWidget>()
    Internal list used to store the last known children collection. Used to detect changes between frames and to provide visibleChildren.

Properties

  • public Unity.Mathematics.float2 position { get; set; }
    Gets or sets the group's position. Setting updates m_Position and calls SetPropertiesChanged() when the value actually changes.

  • public Alignment horizontalAlignment { get; set; }
    Gets or sets the horizontal alignment. Setting updates m_HorizontalAlignment and calls SetPropertiesChanged() if changed.

  • public Alignment verticalAlignment { get; set; }
    Gets or sets the vertical alignment. Setting updates m_VerticalAlignment and calls SetPropertiesChanged() if changed.

  • public Category category { get; set; }
    Gets or sets the category flags for the tooltip group. Setting updates m_Category and calls SetPropertiesChanged() if changed.

  • public System.Collections.Generic.IList<IWidget> children { get; set; } = new System.Collections.Generic.List<IWidget>()
    Public collection of child widgets that belong to this tooltip group. Default-initialized to a new List.

  • public override System.Collections.Generic.IList<IWidget> visibleChildren => m_LastChildren
    Read-only override that exposes the last applied children (m_LastChildren). This is what is considered visible by the layout/rendering system.

Constructors

  • public TooltipGroup()
    Default (implicit) parameterless constructor. The class relies on field initializers (m_LastChildren and children default) and the base Widget constructor. No additional initialization is performed in source.

Methods

  • protected override WidgetChanges Update()
    Called during the widget update cycle. Compares the public children collection with m_LastChildren using SequenceEqual. If the collections differ, marks WidgetChanges.Children, clears m_LastChildren, copies the current children into m_LastChildren, and calls ContainerExtensions.SetDefaults(m_LastChildren) to apply default settings to the new child widgets. Returns the combined WidgetChanges value.

  • protected override void WriteProperties(IJsonWriter writer)
    Serializes the group's properties into the provided IJsonWriter. Calls base.WriteProperties(writer) first, then writes:

  • "position" with the position value,
  • "horizontalAlignment" as the integer value of horizontalAlignment,
  • "verticalAlignment" as the integer value of verticalAlignment,
  • "category" as the integer value of category.

Usage Example

// Example: create a tooltip group, configure it and add children
var tooltipGroup = new TooltipGroup
{
    position = new Unity.Mathematics.float2(12f, 8f),
    horizontalAlignment = TooltipGroup.Alignment.Center,
    verticalAlignment = TooltipGroup.Alignment.End,
    category = TooltipGroup.Category.Network
};

// Add child widgets (IWidget implementations from Game.UI.Widgets)
tooltipGroup.children.Add(new Label { text = "Street capacity" });
tooltipGroup.children.Add(new ValueLabel { value = 42 });

// During update the widget system will call Update(), detect children changes,
// and container defaults will be applied to the new children.