Skip to content

TweenShader

Matheus Lessa Rodrigues edited this page Feb 2, 2018 · 3 revisions

TweenShader

Interpolate shader properties over time.

In its inspector, configure the tween duration and witch properties you wish to interpolate. Also, you can preview how the tween looks like by pressing either the Play Forward or Play Backward button and Clear to return to the original state.

TweenShader

For each property, you can set its to and from state and also its animation curve. Beware that TweenShader only works with properties of type Color, Vector or Float!

Example Code

From code, you can call PlayForward(), PlayBackward(), Stop() and Clear() to play, stop and clear the tween. Also, it's possible to change the duration and access its shaderProperties.

using UnityEngine;
using BitStrap;

public sealed class PlayerDamageFx : MonoBehaviour
{
    public TweenShader tween;

    public void OnReceiveDamage()
    {
        tween.PlayForward();
    }

    public void OnRecoverHealth()
    {
        // Clear() also stops the tween
        tween.Clear();
    }
}
Clone this wiki locally