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.
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
Outline Width Controller
Outline Softness Controller
Outline Color Controller
Further Effects
Effect Settings
Every effect shares the same set of settings:- Start Value – the value of the shader property that the effect starts from.
- End Value – the value of the shader property that the effect ends at.
- Smoothness – the smoothness (i.e., the amount of steps) of the effect. Set it to values above 1000 for exceptionally smooth effects.
- Duration – the duration in seconds needed to go from the start value to the end value.
- Pause Duration – the pause duration in seconds between consecutive effects. After each pause, the effect starts over from the start value.
- Elements – the elements that the effect is applied to. This setting is only shown when Individual Elements is enabled.
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!
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!