I have a bunch of scenes where I need to have multiple text mesh pro components display the same text. At the moment I have just split them out and I’m manually setting the text for each one in code. Just wondering, is there a way to automate that?
I thought there might be a callback or something I could use but I’m not too sure.
The following event is available and used in a few of the TMP examples scenes like 23 - Animating Vertex Attributes which uses the VertexJitter.cs script which makes us of this event.
// Subscribe to event fired when text object has been regenerated.
TMPro_EventManager.TEXT_CHANGED_EVENT.Add(ON_TEXT_CHANGED);
The following event was also added in the latest release to provide for an opportunity to modify the geometry of the text before it is uploaded to the mesh and renderer.
/// <summary>
/// Event to allow users to modify the content of the text info before the text is rendered.
/// </summary>
public override event Action<TMP_TextInfo> OnPreRenderText;
The first event will be more suitable to your use but just wanted to share information about the 2nd one as well.