Controller Script

A controller script – OutlineController.cs – is included for indefinitely lerping the outline effect on a sprite element. If you wish to set up repeating effects, attach this script to any object in your scene, and set it up with the elements and effects you wish to enable. Demo Scene - Complex Effects shows the script in action.

The controller script is independent of the Renderer – the very same script is used on both the Universal Renderer and the 2D Renderer.

The controller script accepts any GameObject elements and searches them for a SpriteRenderer, MeshRenderer, or Graphic component. The script animates a clone of the material of each element, so your material assets are never changed. With Individual Elements enabled, UI elements (Graphic) that use the same material also share the same clone, and thus animate together.

The controller script is split into the following sections, visible in the Editor:

General

The General section contains a single setting – Individual Elements. Leave this setting disabled to have all effects applied to the same elements, which you assign to its Elements list. If you enable this option, you will need to specify (different or the same) elements for each effect you enable!

Outline Width Controller

Lets you customize how the Outline Width changes over time – for example, letting an outline grow from nothing to its full width.

Outline Softness Controller

Lets you customize how the Outline Softness changes over time – for example, letting a hard outline dissolve into a faint glow.

Outline Color Controller

Lets you customize how the Outline Color changes over time, including its HDR intensity.

Further Effects

Each of the remaining shader properties can be lerped independently by enabling its section. The available effects are Color Controller (for the Albedo color), Emission Color Controller (for the Emission Color), and Emission Strength Controller (for the Emission Extra Intensity). Feel free to experiment with different effects and values for each effect.

Effect Settings

Every effect shares the same set of settings:

Inner Outline and Outline Quality cannot be animated with the controller script. Set them on the material. You can have multiple instances of the OutlineController.cs script in your scene, and different effects can target the same elements. However, ensure different instances of the script do not target the same elements!
For example, it is fine to have OutlineController 1 target element A and OutlineController 2 target element B, but do not have both OutlineController 1 and OutlineController 2 target element A!
When enabling several effects at once, it is fine to target the same elements from within the same OutlineController.
For example, it is fine to have the Outline Width effect target elements A and B, and the Outline Color effect target element A as well. Just make sure both effects are inside the same OutlineController script!
General Outline Width Controller Outline Softness Controller Outline Color Controller Further Effects Effect Settings