Game.UI.Widgets.ITooltipTarget
Assembly:
Game (UI assembly for Cities: Skylines 2)
Namespace:
Game.UI.Widgets
Type:
interface
Base:
None (interface)
Summary:
Defines a simple contract for UI widgets that can provide a tooltip. Implementers expose a localized tooltip value (nullable) that the UI tooltip system can read and display when the user hovers or focuses the widget. This is intended for use by in-game UI widgets and modded components that integrate with the game's tooltip display pipeline.
Fields
This interface declares no fields. Implementing types may store their own backing fields as needed.
Properties
LocalizedString? tooltip { get; set; }
Represents the widget's tooltip text as a LocalizedString (nullable). The UI system can query this property to obtain the localized content to show in a tooltip popup. Set to null to indicate no tooltip for the target.
Notes: - LocalizedString is defined in Game.UI.Localization and is used to reference localization keys or localized text resources. - The nullable annotation indicates a widget may intentionally have no tooltip.
Constructors
Interfaces do not define constructors. Implementing classes/structs provide their own construction and initialization logic.
Methods
This interface declares no methods. Tooltip behavior is exposed solely via the property.
Usage Example
using Game.UI.Localization;
using Game.UI.Widgets;
using UnityEngine;
public class MyTooltippedButton : MonoBehaviour, ITooltipTarget
{
// Backing field (optional)
private LocalizedString? m_tooltip;
// Implementation of the interface
public LocalizedString? tooltip
{
get => m_tooltip;
set => m_tooltip = value;
}
void Start()
{
// Assign a localized string (example key). Replace with actual API usage if needed.
tooltip = new LocalizedString("my_mod.button.tooltip");
}
void OnDestroy()
{
// Clear when destroyed or when tooltip no longer applies
tooltip = null;
}
}
Additional info: - Implement this interface on custom UI widget components so the game's tooltip manager can automatically pick up and display tooltip text. - Ensure you use the game's localization APIs and keys for LocalizedString so tooltip text is shown in the player's selected language.