Class TweenCanvasGroupExtensions
Provides extension methods for animating UnityEngine.CanvasGroup components using the Scylla tween system.
Covers alpha (with dedicated fade-in and fade-out helpers) and a full-featured TweenFade(CanvasGroup, float, float, bool) method that optionally updates UnityEngine.CanvasGroup.interactable and UnityEngine.CanvasGroup.blocksRaycasts on completion.
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.CanvasGroup at the moment playback begins,
unless you override it with a SetFrom call before playing.
Inherited Members
Namespace: Scylla.Core.Util.Tween
Assembly: ScyllaCore.dll
Syntax
public static class TweenCanvasGroupExtensions
Methods
TweenAlpha(CanvasGroup, float, float)
Creates a tween that animates the UnityEngine.CanvasGroup.alpha of a canvas group from its
current value to endValue over the specified duration.
The alpha value controls the transparency of all UI elements within the canvas group.
0 is fully transparent and 1 is fully opaque. This method does not
automatically update UnityEngine.CanvasGroup.interactable or
UnityEngine.CanvasGroup.blocksRaycasts; use TweenFade(CanvasGroup, float, float, bool) if you need that
behavior.
Declaration
public static TweenFloat TweenAlpha(this CanvasGroup canvasGroup, float endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| CanvasGroup | canvasGroup | The canvas group whose alpha will be animated. Must not be |
| float | endValue | The target alpha value, typically in the range [0, 1]. |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenFloat | A TweenFloat instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenFade(CanvasGroup, float, float, bool)
Creates a tween that animates the UnityEngine.CanvasGroup.alpha of a canvas group from its
current value to endValue over the specified duration, and optionally updates
UnityEngine.CanvasGroup.interactable and UnityEngine.CanvasGroup.blocksRaycasts when the
animation completes.
When setInteractable is true (the default), an
OnComplete(Action) callback is registered that sets both
UnityEngine.CanvasGroup.interactable and UnityEngine.CanvasGroup.blocksRaycasts to
true if endValue is greater than 0, or to false
if endValue is exactly 0. This ensures the UI is non-interactive
when fully faded out and interactive when visible.
If you need to manage interactability independently, pass setInteractable: false
and handle those flags yourself.
Declaration
public static TweenFloat TweenFade(this CanvasGroup canvasGroup, float endValue, float duration, bool setInteractable = true)
Parameters
| Type | Name | Description |
|---|---|---|
| CanvasGroup | canvasGroup | The canvas group to fade. Must not be |
| float | endValue | The target alpha value, typically in the range [0, 1]. |
| float | duration | The length of the animation in seconds. Pass |
| bool | setInteractable | When |
Returns
| Type | Description |
|---|---|
| TweenFloat | A TweenFloat instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenFadeIn(CanvasGroup, float)
Creates a tween that fades a canvas group in by animating its
UnityEngine.CanvasGroup.alpha from 0 to 1 over the specified duration,
regardless of the canvas group's current alpha.
Unlike TweenAlpha(CanvasGroup, float, float), which starts from the current alpha, this method forces
the start value to 0 via SetFrom(float) so the canvas group always
begins fully transparent. UnityEngine.CanvasGroup.interactable and
UnityEngine.CanvasGroup.blocksRaycasts are not modified - use TweenFade(CanvasGroup, float, float, bool) if
you need those to be updated automatically on completion.
Declaration
public static TweenFloat TweenFadeIn(this CanvasGroup canvasGroup, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| CanvasGroup | canvasGroup | The canvas group to fade in. Must not be |
| float | duration | The length of the fade-in animation in seconds. |
Returns
| Type | Description |
|---|---|
| TweenFloat | A TweenFloat instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenFadeOut(CanvasGroup, float)
Creates a tween that fades a canvas group out by animating its
UnityEngine.CanvasGroup.alpha from its current value to 0 over the specified duration.
UnityEngine.CanvasGroup.interactable and UnityEngine.CanvasGroup.blocksRaycasts are not
modified by this method. Use TweenFade(CanvasGroup, float, float, bool) with setInteractable: true if
you want those flags updated automatically when the fade completes.
Declaration
public static TweenFloat TweenFadeOut(this CanvasGroup canvasGroup, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| CanvasGroup | canvasGroup | The canvas group to fade out. Must not be |
| float | duration | The length of the fade-out animation in seconds. |
Returns
| Type | Description |
|---|---|
| TweenFloat | A TweenFloat instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |