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.
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
| Name | Type | Description |
|---|---|---|
AllowSway | bool | Allows pointer-driven sway. |
Fields
| Name | Type | Description |
|---|---|---|
swayObject | RectTransform | Rectangle that rotates. |
enableXAxis | bool | Allows X-axis rotation. |
enableYAxis | bool | Allows Y-axis rotation. |
smoothness | float | Response speed of the rotation. |
swayIntensity | float | Strength of the tilt. |
Methods
| Name | Parameters | Description |
|---|---|---|
ResetSway() | None | Resets the sway rotation. |
Example
using UnityEngine;
using Evo.UI;
public class RectSwayExample : MonoBehaviour
{
[SerializeField] private RectSway target;
private void Start()
{
target.swayIntensity = 0.75f;
target.AllowSway = true;
}
}