Tooltip
A flexible tooltip system
Overview
Tooltip displays informative text, icons, or custom content when the user hovers over an object. This component is ideal for inventory tooltips, UI explanations, skill descriptions, item previews, and general hover hints.
Usage
Add Tooltip component to any UI or 3D object
Make sure that Preset is assigned
Set title, description, and optional icon
Tooltip will appear when hovered (after showDelay, if any)
Custom Content
Custom content can override the default layout by assigning a Custom Content object, which can be found under the References foldout. It lets you use your own object or prefab as content, which can be useful for more complex layouts.
Customize Preset
- Locate the Preset prefab
- Open the prefab and customize it as needed
Create New Presets
You can create different presets and use them on different objects. To create a new preset:
- Locate the Preset prefab
- Duplicate the prefab (this is the fastest way to customize)
- Open the new prefab and customize it to your liking
Properties
Content
| Name | Type | Description |
|---|---|---|
tooltipPreset | GameObject | Prefab containing TooltipPreset |
title | string | Tooltip title text |
description | string | Tooltip description text |
icon | Sprite | Optional icon |
customContent | GameObject | Prefab replacing default content |
Localization
(Shown only if EVO_LOCALIZATION is enabled)
| Name | Type | Description |
|---|---|---|
enableLocalization | bool | Enables localized content |
localizedObject | LocalizedObject | Reference for localization data |
titleKey | string | Key for localized title |
descriptionKey | string | Key for localized description |
Settings
| Name | Type | Description |
|---|---|---|
followCursor | bool | Follows mouse position when true |
is3DObject | bool | Uses OnMouseEnter and OnMouseExit |
maxWidth | float | Maximum tooltip width |
showDelay | float | Delay before showing |
movementSmoothing | float | Lerp smoothing for follow cursor |
Animation
| Name | Type | Description |
|---|---|---|
animationType | AnimationType | None, Fade, Scale, or Slide |
animationDuration | float | Animation duration |
animationCurve | AnimationCurve | Curve for animation interpolation |
scaleFrom | float | Start scale for Scale animation |
slideOffset | Vector2 | Offset for Slide animation |
AnimationType:
- None
- Fade
- Scale
- Slide
Position and Offset
| Name | Type | Description |
|---|---|---|
offsetPosition | OffsetPosition | Predefined offset direction |
customOffset | Vector2 | Used when offsetPosition is Custom |
offsetDistance | float | Distance from target |
screenEdgePadding | float | Padding from screen bounds |
OffsetPosition supports: Top, Bottom, Left, Right, TopLeft, TopRight, BottomLeft, BottomRight, Custom
References
| Name | Type | Description |
|---|---|---|
tooltipCanvas | Canvas | Canvas used to render tooltip |
Events
| Name | Type | Description |
|---|---|---|
onShow | UnityEvent | Invoked when tooltip begins showing |
onHide | UnityEvent | Invoked when tooltip hides |
Public Methods
| Name | Parameters | Description |
|---|---|---|
Show() | None | Shows tooltip with delay |
Hide() | None | Hides tooltip with animation |
HideImmediate() | None | Immediately destroys tooltip |
SetContent(title, description, icon, custom) | string, string, Sprite, GameObject | Updates tooltip content |
SetContent(customContent) | GameObject | Replaces content with custom UI |
IsVisible() | None | Returns true if tooltip is active |
Code Example
using UnityEngine;
using Evo.UI;
public class TooltipExample : MonoBehaviour
{
public Tooltip tooltip;
void Start()
{
// Change default content
tooltip.title = "Sword of Dawn";
tooltip.description = "A legendary blade forged in ancient light.";
tooltip.icon = someSprite;
// Manual control
// tooltip.Show();
// tooltip.Hide();
// Override content at runtime
tooltip.SetContent("New Title", "Updated description", null);
// Custom UI
// tooltip.SetContent(customPrefab);
// Check visibility
bool visible = tooltip.IsVisible();
}
}