How do I update linkInfo after changing text property?

I want to use links to define a range. Characters in that range will get animated. The problem I have is that after I change text property with some new text like textComponent.text = “new text”, the animation is still running in the same range, despite not having any links. However, if I change it for a text with links, the range changes. For example if I have a code like this:

textComponent.text = "text example <link=anim>number</link> one";
animation.Apply(textComponent);
// ...wait for event to change text...
textComponent.text = "text example number two";
animation.Apply(textComponent);
// ...wait
textComponent.text = "text <link=anim>example</link> number three";
animation.Apply(textComponent);
// ...wait
textComponent.text = "the fourth string"
animation.Apply(textComponent);

on the first change, “number” gets animated as it should. Second change “number” animates again. Third change - “example” is animated as it should. On the last change “ourth st” animates. Possible bug?

Whenever properties of a text object are changed, once per frame, late in the update cycle and just before the frame is rendered, the text object will be processed and the content of the textInfo and sub structures like linkInfo will be updated.

For when you need the text object to be rendered right away instead of when it is normally done, you can use ForceMeshUpdate() on the text object. This result in the text object being process immediately.

Thanks for your reply! ForceMeshUpdate() doesn’t seem to work for linkInfo. But I’ve made this test script:

void Update()
{
    textComponent.ForceMeshUpdate();

    Debug.Log("textInfo.linkCount = " + textComponent.textInfo.linkCount);
    Debug.Log("linkInfo.Length = "    + textComponent.textInfo.linkInfo.Length);
}

Probably didn’t need ForceMeshUpdate() in Update() but whatever.
On the first change it outputs “textInfo.linkCount = 1” and “linkInfo.Length = 1”.
On the second: “textInfo.linkCount = 0” and “linkInfo.Length = 1”.
Third is 1 and 1. Fourth is 0 and 1.

So yeah, I’m sure it’s a bug. But at least now I know how to avoid it so thanks again Stephan!