0
\$\begingroup\$

In my latest project (Unity 2018.4.8f1 - common Mecanim animation) I want to animate a creature just by moving, scaling and changing the letters, it is build of. So I have to change the text of a TextMeshPro UGUI object during animation .

As the text property of TMP UGUI does not show up in property section of the animation panel, I had to write some animation events to get that done with my lettermade hero.

This events are functioning, but NOT executed DURING the PREVIEW of the animation. Same with normal TMP text objects. So it is a bit like animating blindly and then checking the result, correcting blindly again etc.

Is the lack of executing animation events in preview normal behaviour?

How do I get the text change of animated TMP UGUI text in the animation preview?

This is the class with the animation events SetEyes, SetMouth, SetTop:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;


public class Emoji : MonoBehaviour
{
    [SerializeField]
    protected TextMeshProUGUI eyes;
    [SerializeField]
    protected TextMeshProUGUI mouth;
    [SerializeField]
    protected TextMeshProUGUI top;

    protected Animator animator;

    public Animator Animator { get { return animator; } }

    protected void Start()
    {
        animator = GetComponent<Animator>();
    }

    public void SetEyes(string newEyes)
    {
        Debug.Log("Emoji - newEyes: " + newEyes);
        eyes.text = newEyes;
    }

    public void SetMouth(string newMouth)
    {
        Debug.Log("Emoji - newMouth: " + newMouth);
        mouth.text = newMouth;
    }

    public void SetTop(string newTop)
    {
        Debug.Log("Emoji - newTop: " + newTop);
        top.text = newTop;
    }
}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.