Effects
Pointer Trail
A lightweight pointer follow effect for UI elements
Overview
Pointer Trail creates a trail (Image) that follows the mouse pointer. It is useful for adding polish to menus, buttons, and interactive UI sections. The effect supports custom shapes, colors, fading, offset, and visibility modes such as always visible or hover only.
Usage
Add Pointer Trail component to any UI object
Assign a Preset with a shape, color, scale, and fade settings
Set Visibility to:
- Always: the trail is active immediately
- Hover Only: the trail appears only when the pointer enters the object
Optionally assign a Trail Parent to control where the effect appears in the hierarchy
The component will automatically:
- Create a trail object on demand
- Update its position every frame while visible
- Fade in and fade out smoothly
- Remove or hide the instance when leaving the area, depending on settings
Properties
| Name | Type | Description |
|---|---|---|
preset | Preset | Customization settings for the trail appearance and behavior |
visibility | Visibility | Controls when the trail is active (Always or HoverOnly) |
trailParent | Transform | Optional parent object for the generated trail handler |
Preset
| Field | Type | Description |
|---|---|---|
shape | Sprite | Sprite used as the trail shape |
color | Color | Color and initial alpha of the trail |
scale | float | Scale multiplier for the trail image |
offset | Vector2 | Pixel offset applied to the trail position |
fadeDuration | float | Time for fade in and fade out transitions |
Static Methods
These allow manual control without pointer events.
| Name | Parameters | Description |
|---|---|---|
Create(preset, parent, manageParent, shouldDestroy) | Preset, Transform, bool, bool | Creates or shows a trail on a specific parent |
Hide(parent) | Transform | Hides an active trail under a parent |
Code Example
using UnityEngine;
using Evo.UI;
public class PointerTrailExample : MonoBehaviour
{
public PointerTrail pointerTrail;
void Start()
{
// Configure preset
pointerTrail.preset.shape = someSprite; // Assign your sprite
pointerTrail.preset.color = new Color(1f, 1f, 1f, 0.75f);
pointerTrail.preset.scale = 1.2f;
pointerTrail.preset.offset = new Vector2(6f, -4f);
pointerTrail.preset.fadeDuration = 0.15f;
// Set visibility behavior
pointerTrail.visibility = PointerTrail.Visibility.HoverOnly;
}
// Manually creating a trail anywhere in the UI
public void SpawnTrailManually(Transform targetParent)
{
PointerTrail.Create(pointerTrail.preset, targetParent);
}
// Manually hiding a trail
public void HideTrail(Transform targetParent)
{
PointerTrail.Hide(targetParent);
}
}