Skip to content

How to animate the TMPro.TMP_Text.colorGradient property #114

Discussion options

You must be logged in to vote

Here is one of the possible ways to animate the TMPro.TMP_Text.colorGradient property:

using PrimeTween;
using TMPro;
using UnityEngine;

public class PrimeTweenExample : MonoBehaviour {
    [SerializeField] TMP_Text text;
    [SerializeField] TweenSettings tweenSettings;
    [SerializeField] VertexGradient startGradient, endGradient;

    public Tween AnimateTextGradient() {
        return Tween.Custom(this, 0f, 1f, tweenSettings, (target, t) => {
            target.text.colorGradient = LerpVertexGradient(target.startGradient, target.endGradient, t);
        });
        // same as above but allocates GC memory because of delegate allocation
        // more info: https://github.com/Kyrylo…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by KyryloKuzyk
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants