Text Outline, Shadow, Glow and Gradients in Unity Without Material Presets
Last reviewed
Short answer
In TextMesh Pro, outline, shadow and glow are properties of the font material, so every different look needs its own material preset, and gradients are limited to colors at the four corners of each character.
UniText draws fills, strokes, shadows, glows and inner shadows as paint layers that take a color, a linear, radial or angular gradient, or a texture, spread across a glyph, a word, a line or the whole text. Parameters can change per range, so one sentence can mix outline colors and widths.
The usual options
- TextMesh Pro materials. Outline, underlay (shadow), glow and bevel are properties of the distance-field material, and the font's padding limits how far they can reach. No rich-text tag sets an outline or a shadow: a word with a different effect switches to another material with
<font material="…">, and draw calls follow materials. Glow is a shader feature that is stripped from builds unless a material uses it. - TextMesh Pro gradients. Color gradients are single, horizontal, vertical or four-corner colors applied to each character separately through its vertex colors. A gradient across a whole word or a radial gradient is not one of the modes.
- UI Toolkit.
text-shadowand-unity-text-outlinestyle a whole element, work only with distance-field font assets, and have no rich-text tags; gradients use the same four per-character modes. - Effect packages. UIEffect, free and MIT licensed, adds diagonal, angle and radial gradation and several shadow and outline modes to uGUI components, with TextMesh Pro supported through a sample.
Text effects in UniText
- Layers.
FillModifier,StrokeModifier(a true rim around the outline, inside, centered or outside),ShadowModifier,GlowModifier,InnerShadowModifierandExtrudeModifierstack in any number. A stroke works with the fill turned off for outline-only text. - Paints. Every layer takes a solid color, a gradient or a texture. Named paints live in a shared project catalogue, so a brand gradient is defined once.
- Gradients that span the text. A gradient projects linearly, radially or angularly over the glyph, the range, the line or the whole block, so it runs across a sentence instead of restarting on every letter. Stretch, contain, cover and tile fit, and clamp, repeat and mirror spread, control how it fills.
- Per range. Width, color and softness resolve per range, from the Inspector, a tag, a rule or code, so one text can outline a name in gold and a warning in red.
- Blending and order. Layers blend as Normal, Multiply, Screen, Additive or Exclusion, and composite layer by layer or glyph by glyph when neighbors overlap.
- Decorations too. Underline, strikethrough and highlight use the same paints, and underlines can carry their own outline above the text.
Questions
Do I need a new material for every text style?
No. Effects are layers configured on the text, not material properties, so styles differ by their parameters.
Can effects be animated?
Yes. Every effect parameter can be driven by the timeline sequencer, an Animator, Timeline or code, and changed per range.
Check it in your project
Run the browser demo, follow the setup guide, or compare the free version with the licenses.
Related problems
- 3D Text in Unity: Extruded, Bevelled and Lit at RuntimeTextMesh Pro and UI Toolkit text is flat. UniText3D extrudes any text into lit solids at runtime with bevels, per-surface materials, layers, deformers, prefabs on letters, colliders and mesh export.
- Crisp Pixel Fonts in Unity: No Blur, Effects in Whole PixelsPixel fonts blur in Unity when rendered from distance fields, filtered or placed off the grid. UniText detects pixel fonts and renders them texel-exact, with strokes, shadows and animation in whole pixels.
- Typewriter Effect and Text Animation in UnityUniText reveals text with nineteen appearance effects and animates it with wave, shake, bounce and other effects from markup, revealing whole grapheme clusters so every script and emoji appears intact.
