Logo
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.

Preview

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

NameTypeDescription
presetPresetCustomization settings for the trail appearance and behavior
visibilityVisibilityControls when the trail is active (Always or HoverOnly)
trailParentTransformOptional parent object for the generated trail handler

Preset

FieldTypeDescription
shapeSpriteSprite used as the trail shape
colorColorColor and initial alpha of the trail
scalefloatScale multiplier for the trail image
offsetVector2Pixel offset applied to the trail position
fadeDurationfloatTime for fade in and fade out transitions

Static Methods

These allow manual control without pointer events.

NameParametersDescription
Create(preset, parent, manageParent, shouldDestroy)Preset, Transform, bool, boolCreates or shows a trail on a specific parent
Hide(parent)TransformHides an active trail under a parent

Code Example

PointerTrailExample.cs
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);
    }
}

On this page