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
    ColorColorBlackThe color of the shadow.
    Inner Shadow EnabledBoolFalseWhether to render the inner shadow.
    Drop Shadow EnabledBoolFalseWhether to render the drop shadow.
      DistanceFloat[0..64]2.0The distance in pixels that the drop shadow is cast.
      BlurFloat[0..128]4.0The radius of the drop shadow blur in pixels.
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.ShadowColor = Color.black;
filter.InnerShadowEnabled = false;
filter.DropShadowEnabled = false;
filter.ShadowDistance = 2f;
filter.ShadowBlur = 4f;
filter.Strength = 1f;
filter.EndPropertyChange();