Logo
Effects

Rect Sway

Tilt a UI element as the pointer moves over it

Overview

Rect Sway rotates a UI rectangle in response to the pointer. It works well for cards and panels that need a small amount of hover motion.

Preview

Usage

Add Rect Sway and assign Sway Object.

Enable the axes you want to animate.

Adjust intensity and smoothness.

Keep the receiving object raycastable so hover events can reach the component.


Tips

Use one axis for a restrained tilt, or both for a card-like effect.


Public API

Use RectSway in the Evo.UI namespace.

Properties

NameTypeDescription
AllowSwayboolAllows pointer-driven sway.

Fields

NameTypeDescription
swayObjectRectTransformRectangle that rotates.
enableXAxisboolAllows X-axis rotation.
enableYAxisboolAllows Y-axis rotation.
smoothnessfloatResponse speed of the rotation.
swayIntensityfloatStrength of the tilt.

Methods

NameParametersDescription
ResetSway()NoneResets the sway rotation.

Example

RectSwayExample.cs
using UnityEngine;
using Evo.UI;

public class RectSwayExample : MonoBehaviour
{
    [SerializeField] private RectSway target;

    private void Start()
    {
        target.swayIntensity = 0.75f;
        target.AllowSway = true;
    }
}

On this page