Class TweenMaterialExtensions
Provides extension methods for animating UnityEngine.Material properties using the Scylla tween system.
Covers the main color, named and ID-keyed color properties, the main alpha channel, named and ID-keyed float properties, named and ID-keyed vector (Vector4) properties, as well as the main texture offset and scale.
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 material at the moment playback begins, unless you override it
with a SetFrom call before playing.
Overloads that accept an int property ID use the pre-hashed identifier returned by
PropertyToID(string), which is faster than the string-based lookups performed by
overloads that accept a property name. Prefer the ID overloads in performance-sensitive code.
Inherited Members
Namespace: Scylla.Core.Util.Tween
Assembly: ScyllaCore.dll
Syntax
public static class TweenMaterialExtensions
Methods
TweenAlpha(Material, float, float)
Creates a tween that animates only the alpha channel of the material's main color
(_Color) from its current 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 keeping the RGB values of the current color intact at each frame.
Declaration
public static TweenColor TweenAlpha(this Material material, float endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| Material | material | The material whose main color 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(Material, Color, float) instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenColor(Material, int, Color, float)
Creates a tween that animates a color property of a material identified by a pre-hashed
property ID from its current value to endValue over the specified duration.
Uses GetColor(int) and SetColor(int, Color) internally, bypassing the string-lookup overhead present in the name-based overload. Obtain the ID once with PropertyToID(string) and cache it for repeated use.
Declaration
public static TweenColor TweenColor(this Material material, int propertyID, Color endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| Material | material | The material to animate. Must not be |
| int | propertyID | The pre-hashed shader property identifier obtained from PropertyToID(string). |
| Color | endValue | The target color value for the specified property. |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenColor | A TweenColor(Material, Color, float) instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenColor(Material, string, Color, float)
Creates a tween that animates a named color property of a material from its current value to
endValue over the specified duration.
Uses GetColor(string) and SetColor(string, Color) internally. If the property name does not exist on the material's shader, Unity will silently use a default value. Prefer the ID overload TweenColor(Material, int, Color, float) for better runtime performance.
Declaration
public static TweenColor TweenColor(this Material material, string propertyName, Color endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| Material | material | The material to animate. Must not be |
| string | propertyName | The name of the shader color property to animate (e.g., |
| Color | endValue | The target color value for the specified property. |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenColor | A TweenColor(Material, Color, float) instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenColor(Material, Color, float)
Creates a tween that animates the main color property (_Color) of a material from its
current value to endValue over the specified duration.
Equivalent to calling material.color as getter and setter. All four RGBA channels
are interpolated simultaneously. Use TweenAlpha(Material, float, float) if
you only want to animate the alpha channel.
Declaration
public static TweenColor TweenColor(this Material material, Color endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| Material | material | The material whose main 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(Material, Color, float) instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenFloat(Material, int, float, float)
Creates a tween that animates a float property of a material identified by a pre-hashed
property ID from its current value to endValue over the specified duration.
Uses GetFloat(int) and SetFloat(int, float) internally, avoiding the string-hash lookup overhead of the name-based overload. Obtain the ID once with PropertyToID(string) and cache it.
Declaration
public static TweenFloat TweenFloat(this Material material, int propertyID, float endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| Material | material | The material to animate. Must not be |
| int | propertyID | The pre-hashed shader property identifier obtained from PropertyToID(string). |
| float | endValue | The target float value for the specified property. |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenFloat | A TweenFloat(Material, string, float, float) instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenFloat(Material, string, float, float)
Creates a tween that animates a named float property of a material from its current value to
endValue over the specified duration.
Uses GetFloat(string) and SetFloat(string, float) internally. Prefer the ID overload TweenFloat(Material, int, float, float) for better runtime performance in hot paths.
Declaration
public static TweenFloat TweenFloat(this Material material, string propertyName, float endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| Material | material | The material to animate. Must not be |
| string | propertyName | The name of the shader float property to animate (e.g., |
| float | endValue | The target float value for the specified property. |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenFloat | A TweenFloat(Material, string, float, float) instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenTextureOffset(Material, Vector2, float)
Creates a tween that animates the UnityEngine.Material.mainTextureOffset of a material from
its current value to endValue over the specified duration.
The main texture offset controls the UV tiling origin for the primary texture slot
(_MainTex / _BaseMap). Animating this value is useful for scroll effects,
UV-based animations, or parallax backgrounds.
Declaration
public static TweenVector2 TweenTextureOffset(this Material material, Vector2 endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| Material | material | The material whose main texture offset will be animated. Must not be |
| Vector2 | endValue | The target UV offset as a UnityEngine.Vector2. Each component is typically in the range [0, 1] but can exceed those bounds for continuous scrolling. |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenVector2 | A TweenVector2 instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenTextureScale(Material, Vector2, float)
Creates a tween that animates the UnityEngine.Material.mainTextureScale of a material from
its current value to endValue over the specified duration.
The main texture scale controls the UV tiling multiplier for the primary texture slot
(_MainTex / _BaseMap). Increasing the scale tiles the texture more densely;
decreasing it stretches it. Animating this value is useful for zoom effects or procedural
texture transitions.
Declaration
public static TweenVector2 TweenTextureScale(this Material material, Vector2 endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| Material | material | The material whose main texture scale will be animated. Must not be |
| Vector2 | endValue | The target UV scale as a UnityEngine.Vector2. A value of |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenVector2 | A TweenVector2 instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenVector(Material, int, Vector4, float)
Creates a tween that animates a Vector4 property of a material identified by a pre-hashed
property ID from its current value to endValue over the specified duration.
Uses GetVector(int) and SetVector(int, Vector4) internally, avoiding the string-hash lookup overhead of the name-based overload. Obtain the ID once with PropertyToID(string) and cache it.
Declaration
public static TweenVector4 TweenVector(this Material material, int propertyID, Vector4 endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| Material | material | The material to animate. Must not be |
| int | propertyID | The pre-hashed shader property identifier obtained from PropertyToID(string). |
| Vector4 | endValue | The target UnityEngine.Vector4 value for the specified property. |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenVector4 | A TweenVector4 instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |
See Also
TweenVector(Material, string, Vector4, float)
Creates a tween that animates a named Vector4 property of a material from its current value to
endValue over the specified duration.
Uses GetVector(string) and SetVector(string, Vector4) internally. All four components are interpolated simultaneously. Prefer the ID overload TweenVector(Material, int, Vector4, float) for better runtime performance.
Declaration
public static TweenVector4 TweenVector(this Material material, string propertyName, Vector4 endValue, float duration)
Parameters
| Type | Name | Description |
|---|---|---|
| Material | material | The material to animate. Must not be |
| string | propertyName | The name of the shader Vector4 property to animate (e.g., |
| Vector4 | endValue | The target UnityEngine.Vector4 value for the specified property. |
| float | duration | The length of the animation in seconds. Pass |
Returns
| Type | Description |
|---|---|
| TweenVector4 | A TweenVector4 instance ready for configuration and playback. Call Play() or PlayManaged(ITween) to start the animation. |