Game.UI.Tooltip.InputHintsTooltipSystem
Assembly: Assembly-CSharp
Namespace: Game.UI.Tooltip
Type: class
Base: TooltipSystemBase
Summary:
InputHintsTooltipSystem is an in-world UI system that builds and shows input hint tooltips for the currently active tool. It listens for changes to the active tool and the active control scheme (keyboard/mouse vs. gamepad), caches InputHintTooltip instances per ProxyAction, and during each update refreshes and pushes matching hints to the tooltip display (via AddMouseTooltip). The system filters hints by the current DeviceType and by a ProxyAction's display override priority.
Fields
-
private ToolSystem m_ToolSystem
Reference to the global ToolSystem obtained from the world. Used to read the current active tool and its available actions. -
private ToolBaseSystem m_LastActiveTool
Stores the last observed active tool so the system can detect when the tool has changed and rebuild the tooltip set. -
private InputManager.ControlScheme m_ControlScheme
Stores the last observed control scheme (KeyboardAndMouse, Gamepad, etc.) so the system can detect control-scheme changes and rebuild the tooltip set. -
private readonly Dictionary<ProxyAction, InputHintTooltip> m_Tooltips = new Dictionary<ProxyAction, InputHintTooltip>()
Cache of InputHintTooltip objects keyed by ProxyAction. Rebuilt when the active tool or control scheme changes. Used to avoid reallocating tooltip objects each frame.
Properties
- This class does not expose any public properties.
Constructors
public InputHintsTooltipSystem()
Default constructor. Marked with [Preserve] in the source to prevent stripping by code-stripping tools.
Methods
protected override void OnCreate()
: System.Void- Marked with [Preserve].
-
Calls base.OnCreate() and resolves m_ToolSystem by calling base.World.GetOrCreateSystemManaged
(). Prepares the system to read the active tool each update. -
protected override void OnUpdate()
: System.Void - Marked with [Preserve].
- Main per-frame logic:
- Reads the currently active tool from m_ToolSystem.activeTool.
- Maps InputManager.instance.activeControlScheme to an InputManager.DeviceType (Gamepad -> DeviceType.Gamepad, KeyboardAndMouse -> DeviceType.Mouse, otherwise None).
- If the active tool or control scheme changed since the last update:
- Updates m_LastActiveTool and m_ControlScheme.
- Clears m_Tooltips and, if there is a new active tool, iterates all of that tool's actions:
- If the action is a state action (UIBaseInputAction.IState), it iterates the state's actions and adds a new InputHintTooltip for each ProxyAction not already present.
- If the action is a direct ProxyAction, adds an InputHintTooltip for it if not already present.
- Iterates the entries in m_Tooltips and for each pair (proxyAction, inputHintTooltip):
- If (proxyAction.mask & deviceType) != None AND proxyAction.displayOverride != null AND proxyAction.displayOverride.priority != -1:
- Calls inputHintTooltip.Refresh() and then AddMouseTooltip(inputHintTooltip) to queue the tooltip for display.
- Notes:
- The system filters by proxyAction.mask against the current device type and also by displayOverride priority.
- AddMouseTooltip is provided by the base class (TooltipSystemBase) to register tooltip visuals for this frame.
Usage Example
[Preserve]
protected override void OnCreate()
{
base.OnCreate();
// Resolve the tool system so this TooltipSystem can read the active tool
m_ToolSystem = base.World.GetOrCreateSystemManaged<ToolSystem>();
}
// The OnUpdate implementation in this system is responsible for building
// and refreshing InputHintTooltip instances for the active tool and control scheme.
Additional notes for modders: - To add or modify hints for a custom tool, ensure that your ProxyAction instances have the correct mask bits for the targeted device type(s) and provide a displayOverride with a valid priority (not -1) to make them visible. - If you need a custom tooltip rendering behavior, extend InputHintTooltip and ensure the system constructs and registers your custom tooltip type instead of the default. - The system recreates its cache when the tool or control scheme changes, so changes to actions at runtime require updating the active tool or control scheme (or trigger the same behavior) to be picked up. - This system runs on the main thread and interacts with Unity-managed UI; avoid doing heavy work inside OnUpdate for performance reasons.