Skip to content

Game.UI.Tooltip.GuideLineTooltipSystem

Assembly:
Assembly-CSharp (game assembly)

Namespace:
Game.UI.Tooltip

Type:
public class GuideLineTooltipSystem

Base:
TooltipSystemBase

Summary:
GuideLineTooltipSystem is a UI tooltip system used to display floating measurement tooltips for guide lines (for example length and angle indicators) in the game world. It queries the GuideLinesSystem for tooltip data each frame, converts world positions to tooltip coordinates, reuses or creates TooltipGroup instances, populates a FloatTooltip child with icon/value/unit information and enqueues the group for rendering. The system ensures job dependencies returned by GuideLinesSystem are completed before reading the NativeList of tooltip infos.


Fields

  • private GuideLinesSystem m_GuideLinesSystem
    Reference to the game's GuideLinesSystem. Used to obtain the current guide line tooltip data (positions, values and types).

  • private List<TooltipGroup> m_Groups
    A reusable list of TooltipGroup instances. The system reuses these groups across frames to avoid reallocations and to update positions/contents of existing groups rather than creating new UI objects every update.

Properties

  • This class does not expose public properties.

Constructors

  • public GuideLineTooltipSystem()
    Default constructor. Marked with [Preserve] in source so the method is kept by stripping tools. Initialization of fields is performed in OnCreate rather than the constructor.

Methods

  • protected override void OnCreate()
    Initializes runtime references and collections:
  • Calls base.OnCreate().
  • Retrieves or creates the GuideLinesSystem instance from the world (m_GuideLinesSystem).
  • Initializes the m_Groups list to hold TooltipGroup objects that will be reused each frame.

  • protected override void OnUpdate()
    Main per-frame logic:

  • Calls m_GuideLinesSystem.GetTooltips(out dependencies) to obtain a NativeList and a JobHandle representing work required to produce that list.
  • Calls dependencies.Complete() to ensure the data is ready and safe to read on the main thread.
  • Iterates the NativeList of tooltip infos. For each entry:
    • Ensures there is a corresponding TooltipGroup in m_Groups; creates one with:
    • path = $"guideLineTooltip{i}"
    • horizontalAlignment = TooltipGroup.Alignment.Center
    • verticalAlignment = TooltipGroup.Alignment.Center
    • category = TooltipGroup.Category.Network
    • children containing a FloatTooltip instance
    • Converts the tooltip world position to tooltip UI coordinates using TooltipSystemBase.WorldToTooltipPos(..., out onScreen). If the group position changes, updates the TooltipGroup.position and calls SetChildrenChanged() to notify the UI system.
    • Casts the first child to FloatTooltip and sets the icon, value and unit based on the GuideLinesSystem.TooltipType:
    • Angle: icon "Media/Glyphs/Angle.svg", unit "angle"
    • Length: icon "Media/Glyphs/Length.svg", unit "length"
    • Calls AddGroup(tooltipGroup) to enqueue the group for rendering as a tooltip.
  • Notes:
    • The method intentionally completes the job handle before iterating the NativeList to avoid race conditions.
    • The code reuses TooltipGroup objects and their child FloatTooltip instances to minimize allocations each frame.

Usage Example

[Preserve]
protected override void OnCreate()
{
    base.OnCreate();
    // This is the same behavior as the system's implementation:
    m_GuideLinesSystem = base.World.GetOrCreateSystemManaged<GuideLinesSystem>();
    m_Groups = new List<TooltipGroup>();
}

Additional notes: - The system relies on the GuideLinesSystem to supply tooltip data via a NativeList. The lifecycle (allocation/disposal) of that list is managed by GuideLinesSystem.GetTooltips; consumers must respect the returned JobHandle and complete it before reading. - FloatTooltip children are assumed to expose at least the following members used here: icon (string path), value (float or numeric), and unit (string). The system sets the icon to in-game SVG glyphs for angle/length.