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

Preview

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

SpaceResult
LocalThe gradient spans the Graphic's own mesh.
Screen SpaceThe 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

NameTypeDescription
gradientEffectGradientGradient applied to the vertices.
gradientTypeTypeHorizontal or Vertical base direction.
gradientSpaceProceduralShape.GradientSpaceLocal or Screen Space.
blendModeBlendModeHow gradient colors combine with existing colors.
anglefloatGradient rotation.
effectOffsetfloatGradient offset.
zoomfloatGradient scale.
reverseboolReverses color order.

Methods

NameParametersDescription
UpdateGradient()NoneRefreshes the gradient and the mesh.
SetGradient()Gradient newGradientReplaces the gradient.
SetGradientColors()Color startColor, Color endColorCreates a two-color gradient.

Example

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

On this page