Effects
Image Gradient
Apply a vertex gradient to a UI Graphic
Overview
Image Gradient applies gradient colors to a Graphic's mesh. It adds vertices only where the blend needs them, so colors follow the gradient like Procedural Shape gradients do, within two 8-bit levels.
Usage
Add Image Gradient to the Graphic you want to tint.
Edit the gradient and choose its direction.
Choose the space the gradient spans.
Select how it blends with existing vertex colors.
Adjust angle, zoom, offset, or reverse direction.
Gradient Space
| Space | Result |
|---|---|
| Local | The gradient spans the Graphic's own mesh. |
| Screen Space | The gradient spans the root Canvas, which is the screen for Overlay and Camera canvases. Graphics side by side share one continuous gradient, and colors stay in place while a Graphic moves. |
A Screen Space gradient rebuilds its mesh when the Graphic moves along the gradient. Moves across it, like a vertical scroll under a horizontal gradient, don't rebuild anything.
Public API
Use ImageGradient in the Evo.UI namespace.
Call UpdateGradient() after editing gradientEffect in place or changing a field from code.
Fields
| Name | Type | Description |
|---|---|---|
gradientEffect | Gradient | Gradient applied to the vertices. |
gradientType | Type | Horizontal or Vertical base direction. |
gradientSpace | ProceduralShape.GradientSpace | Local or Screen Space. |
blendMode | BlendMode | How gradient colors combine with existing colors. |
angle | float | Gradient rotation. |
effectOffset | float | Gradient offset. |
zoom | float | Gradient scale. |
reverse | bool | Reverses color order. |
Methods
| Name | Parameters | Description |
|---|---|---|
UpdateGradient() | None | Refreshes the gradient and the mesh. |
SetGradient() | Gradient newGradient | Replaces the gradient. |
SetGradientColors() | Color startColor, Color endColor | Creates a two-color gradient. |
Example
using UnityEngine;
using Evo.UI;
public class ImageGradientExample : MonoBehaviour
{
[SerializeField] private ImageGradient target;
private void Start()
{
target.SetGradientColors(Color.cyan, Color.blue);
target.angle = 30f;
target.gradientSpace = ProceduralShape.GradientSpace.ScreenSpace;
target.UpdateGradient();
}
}