Forum rules - please read before posting.

TMPro integration - support multiple text pairs with single instance

edited April 2021 in Extending the editor


Over on the wiki there is an excellent script which is for Text Mesh Pro integration

I've been using this for a while however you have to add this as a component to each pair of text and TMPro objects you want to link. For instance, if you have a UI prefab like this:

You have to add the script five times.

I'm always keen to use less components if possible, so I was interested if it would be possible to just use a single instance of the script, but to still handle multiple text object pairs.

My modification:

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

public class TextLinks
    public Text textToCopyFrom;
    public TextMeshProUGUI textMeshToCopyTo;

public class TextMeshPro_AC_New : MonoBehaviour
    public TextLinks[] textLinks;

    private void Update()
        for (int i = 0; i < textLinks.Length; i++)
            textLinks[i].textMeshToCopyTo.text = textLinks[i].textToCopyFrom.text;

The above allows you to have a single instance of the script and add as many text pairs as you like:

I guess the main upside is if you have a UI prefab with a lot of text & TMPro elements all the links can be seen in a single place.

Not sure if you'd consider that an improvement, but I thought I'd share regardless.


  • edited April 2021

    Of course, it's only now I've spotted that:


    AC's TextMesh Pro integration is now built-in! See the Manual's "Supported third-party assets" for instructions.

    That's my new job this afternoon then!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.