Skip to main content

Extrude Filter Component

Component Screenshot

Overview

This component adds an extrusion effect to the UI object it is applied to.

WebGL Demo

Properties

Component Screenshot

Property                            Type    Range    DefaultDescription
Extrude
    ProjectionEnumPerspectiveWhich projection method to use. Options are:
Perspective - Gives a perspective illusion of 3D depth by extruding towards a focal point.
Orthographic - The extrusion is based only on an angle and direction. This option is less computationally expensive than Perspective.
    AngleFloat[0..360]135.0The angle of extrusion in degrees. In Perspective projection mode this indicates the angle to the focal point from the center of the source Graphic.
    Perspective DistanceFloat[0..512]0.0In Perspective projection mode this indicates the distance along the angle to the focal point from the center of the source Graphic.
    DistanceFloat[0..512]32.0The length in pixels of the extrusion. In Perspective projection mode it doesn't correspond directly to pixels but is still approximately proportional.
Fill
    ModeEnumBi ColorThe method to use to fill the extrusion with color. Options are:
Color - Fill with a single color.
Bi Color - Fill with a color interpolated between two colors based on the distance along the extrusion.
Gradient - Fill with a Gradient based on the distance along the extrusion.
Texture - Fill with a 2D horizontal gradient texture based on the distance long the extrusion.
    ColorColorGreyThe main color to fill with.
    Back ColorColorClearThe second color to fill with in Bi Color mode.
    Scroll Delta TimeEnumNormalThe time delta to use when updating scrolling. Options are:
Normal: Use Time.deltaTime.
Unscaled: Use Time.unscaledDeltaTime, but use Time.captureDeltaTime if it is set.
    Scroll SpeedFloat[-inf..inf]0.0The speed at which to animate the fill mode.
    ReverseBoolFalseIn Bi Color, Gradient and Texture fill modes, this creates reverses the gradient.
    Blend ModeEnumMultiplyThe color blending mode to use for blending the fill mode with the source Graphic colors. Options are:
.• Replace - Ignore the source Graphic color and just use the fill color.
Multiply Multiply the source Graphic color by the fill color.
Apply
    Source AlphaFloat[0..1]1.0Fades the source Graphic.
    Composite ModeEnumNormalWhich mode to use when compositing the extrusion. Options are:
Normal - Extrusion is composited behind the source graphic.
Cutout - Extrusion is rendered with the source graphic cut out from it.
Shadow - Only the extrusion is rendered.
    StrengthFloat[0..1]1.0Strength of the effect.
    Render SpaceEnumCanvasWhich coordinate system use when rendering this filter. Options are:
Canvas: Render the filter before any transforms (scale/rotation/translation etc) are applied.
Screen: Render the filter after transforms have been applied.
Read more about this property here.
    ExpandEnumExpandWhether to expand the Graphic area to accommodate this filter overflowing the original bounds. Setting this to None can be useful when applying effects to content you want to enclose in a frame using something like the FrameFilter component.

Usage

Add this component to any GameObject that contains a UI Graphic component (eg Text, Image, RawImage, etc). The object will now render with an extrusion effect.

Usage with TextMeshPro

To use this filter effect with TextMeshPro - Text (UI) use the Filter Stack (TextMeshPro) component.

Examples

Scripting

Namespace

The namespace
using ChocDino.UIFX;

Adding the ExtrudeFilter Component

Add the ExtrudeFilter component to your GameObject
// Add the component to your GameObject and set default properties
var extrude = AddComponent<ExtrudeFilter>();

extrude.BeginPropertyChange();
extrude.Projection = ExtrudeProjection.Perspective;
extrude.Angle = 135f;
extrude.PerspectiveDistance = 0f;
extrude.Distance = 32f;
extrude.FillMode = ExtrudeFillMode.BiColor;
extrude.ColorFront = Color.grey;
extrude.ColorBack = Color.clear;
extrude.FillBlendMode = ExtrudeFillBlendMode.Multiply;
extrude.ScrollSpeed = 0f;
extrude.ReverseFill = false;
extrude.SourceAlpha = 1f;
extrude.CompositeMode = LongShadowCompositeMode.Normal;
extrude.Strength = 1f;
extrude.EndPropertyChange();

Adjusting gradient color in ExtrudeFilter Component

Adjusting gradient color
// Adjust the gradient color
// NOTE: That you have to assign the whole array (GradientColorKey[] or GradientAlphaKey[]) to Gradient. You can't just adjust the values of the individual keys without reassigning the entire array, otherwise it will not update.
var extrude = GetComponent<ExtrudeFilter>();
var gc = extrude.Gradient.colorKeys;
gc[0] = new GradientColorKey(new Color(Random.value, Random.value, Random.value, 1f), gc[0].time);
extrude.Gradient.colorKeys = gc;