Forum rules - please read before posting.

Remember TextMeshProUGUI text?

Hi all,

Hope you are doing well!
Is it possible to remember text when going in and out of a scene?

I noticed that text objects that I am dynamically updating in a scene do not retain their changes when I step out of the scene and then go back in.

I tried looking at the available options for "Remember __" scripts, but I didn't see anything that would match scripts. Global variables would not work in this case it seems, since it's a regular GUI element -- not an AC-linked one.

Any help is appreciated, thank you!

Comments

  • If it's not linked to an AC Menu or Variable, you'll need to write a custom Remember component to record the text.

    This tutorial covers the process.

  • Ah got it, thank you so much! Looks like this worked!

  • @ChrisIceBox Is it possible to link a textmeshpro object to a variable?
    I tried putting in [localvar:0] in the textmeshpro object but when I click play, it still shows up as [localvar:0] instead of its value.

  • The ConvertTokens function can be used in custom scripts to manually replace tokens with their variable values.

    The brute-force technique would be to set this in an Update loop, i.e.:

    using UnityEngine;
    
    public class TMProTokenText : MonoBehaviour
    {
    
        public string originalText;
        public TMPro.TextMeshProUGUI uiText;
    
        void Update ()
        {
            string convertedText = AC.AdvGame.ConvertTokens (originalText);
            uiText.text = convertedText;
        }
    }
    
  • Awesome, thank you so much!

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.