Class TweenSpriteRendererExtensions
Provides extension methods for animating UnityEngine.SpriteRenderer components using the Scylla tween system.
Covers the full RGBA color, alpha-only transitions, and dedicated fade-in and fade-out helpers.
All methods return a pre-configured tween instance sourced from TweenPool. The
tween is not started automatically - call Play() or
PlayManaged(ITween) on the returned instance to begin playback. The start
value is captured lazily from the UnityEngine.SpriteRenderer at the moment playback begins,
unless you override it with a SetFrom or SetFromAlpha call before playing.
Inherited Members
Namespace: Scylla.Core.Util.Tween
Assembly: ScyllaCore.dll
Syntax
public static class TweenSpriteRendererExtensions
Methods
TweenAlpha(SpriteRenderer, float, float)
Creates a tween that animates only the alpha channel of the
UnityEngine.SpriteRenderer.color from its current alpha value to
endValue over the specified duration, preserving the RGB channels throughout.
Internally uses InitializeAlpha(Func<Color>, Action<Color>, float, float), which interpolates only the alpha component while the RGB values of the sprite renderer's current color remain unmodified at each frame.
Declaration
public static TweenColor TweenAlpha(this SpriteRenderer spriteRenderer, float endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| SpriteRenderer | spriteRenderer | The sprite renderer whose alpha will be animated. Must not be |
| float | endValue | The target alpha value in the range [0, 1], where |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenColor | A TweenColor(SpriteRenderer, Color, float) instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenColor(SpriteRenderer, Color, float)
Creates a tween that animates the UnityEngine.SpriteRenderer.color of a sprite renderer from
its current value to endValue over the specified duration.
All four RGBA channels are interpolated simultaneously. To animate only the alpha channel while preserving the RGB values, use TweenAlpha(SpriteRenderer, float, float) instead.
Declaration
public static TweenColor TweenColor(this SpriteRenderer spriteRenderer, Color endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| SpriteRenderer | spriteRenderer | The sprite renderer whose color will be animated. Must not be |
| Color | endValue | The target color, including alpha. |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenColor | A TweenColor(SpriteRenderer, Color, float) instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenFadeIn(SpriteRenderer, float)
Creates a tween that fades a sprite renderer in by animating the alpha channel of its
UnityEngine.SpriteRenderer.color from 0 to 1 over the specified duration,
regardless of the sprite renderer's current alpha.
Unlike TweenAlpha(SpriteRenderer, float, float), which starts from the current alpha, this method forces
the start alpha to 0 via SetFromAlpha(float) so the sprite always
begins fully transparent. The RGB channels of the sprite renderer's color are preserved
throughout the animation.
Declaration
public static TweenColor TweenFadeIn(this SpriteRenderer spriteRenderer, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| SpriteRenderer | spriteRenderer | The sprite renderer to fade in. Must not be |
| float | duration | The length of the fade-in animation in seconds. |
Returns
| Type | Description |
|---|---|
| TweenColor | A TweenColor(SpriteRenderer, Color, float) instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenFadeOut(SpriteRenderer, float)
Creates a tween that fades a sprite renderer out by animating the alpha channel of its
UnityEngine.SpriteRenderer.color from its current alpha value to 0 over the specified
duration, preserving the RGB channels throughout.
Declaration
public static TweenColor TweenFadeOut(this SpriteRenderer spriteRenderer, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| SpriteRenderer | spriteRenderer | The sprite renderer to fade out. Must not be |
| float | duration | The length of the fade-out animation in seconds. |
Returns
| Type | Description |
|---|---|
| TweenColor | A TweenColor(SpriteRenderer, Color, float) instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |