Fading Image objects
Quick Start
From an empty scene, do the following:
- Create an empty GameObject and add a Director component to it
- Copy the sequential images in a folder inside the Unity project, preferably under StreamingAssets > Copying to a folder under StreamingAssets will save us from the process to import those images in Unity, which may take a long time if there are a lot of images
- Open the Timeline window
Add a FaderTrack in the Timeline Window
Right click on the timeline window and click Add Fader Playable Asset
Create an Image object by clicking the menu: GameObject -> UI -> Image
Drag and drop the Image object to the object property of the FaderTrack
The Image object will be faded in/out as we play the Timeline or drag the time slider of the Timeline window.
Gap Extrapolation
The behaviour of a gap before or after a FaderPlayableAsset clip can be set in a similar way to setting gap extrapolation for Animation clips using one of the following options:
- None (default): hide the bound object by deactivating its Renderer component.
- Hold: hold and show the first/last state of the fading in the gap.
- Loop: loop the entire fading with the same clip duration.
- Ping Pong: loop the entire fading backwards, then forwards, and so forth, with the same clip duration.
- Continue: same as Hold
By default, FaderPlayableAsset sets both Pre-Extrapolate and Post-Extrapolate properties to None.
FaderPlayableAsset
FaderPlayableAsset is a type of
PlayableAsset
which is used for fading Image component in
Unity Timeline.
We can view or modify the following properties through the inspector.
- Color
The color to be applied to the Image component attached to the track. - Fade Type
- FadeIn : from invisible (alpha=0) to visible (alpha=1)
- FadeOut: from visible (alpha=1) to invisible (alpha=0)