Skip to content

Unified Outline

A component was created (All1CreateUnifiedOutline) to automate the sprite duplication task that is usually used to create a Unified Outline. This effect is achieved by adding an additional sprite behind each original sprite we want to outline:

Three overlapping soldiers, orange, green and blue, wrapped in one glowing white outline around the whole group, labelled Unified Outline

(Example available in the Demo scene)

The demo's three overlapping soldiers bobbing up and down. With the outline effect on each sprite, every soldier's outline cuts across the ones behind it; with the Unified Outline there is one outline around the whole group

With the All1CreateUnifiedOutline component we can do that automatically by adding it to the parent gameobject of the hierarchy we want to outline:

The All1CreateUnifiedOutline component: Outline Material, Outline Parent Transform, the duplicate order in layer and sorting layer, and the Create Unified Outline checkbox

To use it we need to add an Outline Material to the first slot. We can do so by saving a material with the desired outline (see Component Features if you don’t know how). The Outline Parent Transform is optional. If added, all the new outline gameobjects will be placed under this transform, otherwise the duplicates will be placed under the gameobject they’ve been duplicated from.

The next 2 properties are used to set the order in layer and sorting layer of the outline sprites. We’ll want to place them behind the original sprite. But it’s up to you what order in layer and sorting layer they use.

To create the Unified Outline press the Create Unified Outline checkbox. This will set up everything for you and will then delete the component.

Two things to know about the copies it makes:

  • Each copy takes its part’s sprite and flip once, when it is made. An animation that swaps sprites, such as a frame by frame walk cycle, leaves the outline showing the first frame.
  • With an Outline Parent Transform, the copies stop following their parts. Under their own parts they move, turn and scale with them; placed under another transform they stay where they were made.

A step by step guide, with the other ways to outline a sprite: How to Add an Outline to a Sprite in Unity.