Skip to main content

Edge Lighting Filter Component

Overview

This component is used to add a lighting and shadow effect to a UI element.

Component Screenshot

WebGL Demo

Properties

Component Screenshot

Property                            Type    Range    DefaultDescription
Light
    AngleFloat[0..360]135.0The clockwise angle for the lighting (and shadow).
    DistanceFloat[0..32]2.0The distance in pixels to inset the edge lighting.
    BlurFloat[0..32]2.0The radius of the edge lighting blur in pixels.
    ColorColorWhiteThe color of the light.
Shadow
    EnabledBoolTrue32.0The length of the blur in pixels.
    DistanceFloat[0..64]2.0The distance in pixels that the shadow is cast.
    BlurFloat[0..128]4.0The radius of the shadow blur in pixels.
    ColorColorBlackThe color of the shadow.
Apply
    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.
    StrengthFloat[0..1]1.0Strength of the effect.

Usage

Add this component to any GameObject that contains a UI Graphic component (eg Text, Image, RawImage, etc).

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 EdgeLightingFilter Component

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

filter.BeginPropertyChange();
filter.Angle = 135f;
filter.Distance = 2f;
filter.Blur = 2f;
filter.LightColor = Color.white;
filter.ShadowEnabled = true;
filter.ShadowColor = Color.black;
filter.ShadowBlur = 4f;
filter.ShadowDistance = 2f;
filter.Strength = 1f;
filter.EndPropertyChange();