How to update String Reference of Localize String Event at runtime?

Hello there,

I’m trying to update a String Reference at runtime.
Usually I set these in the Editor, but now I’m in a situation where I would need to have just one TMP_Text and its Localize String Event will be updated at runtime.

But I cannot find how to get the “Localized String” that it’s waiting for.
Can someone help me complete the code below?
I usually use LocalizationSettings.StringDatabase.GetLocalizedString(“UITexts”, key); but this returns a String, and not a Localized String.

    [Header("LOCALIZATION")]
    public UnityEngine.Localization.Components.LocalizeStringEvent masteryBaseDescriptionLSE;
    public UnityEngine.Localization.SmartFormat.PersistentVariables.IntVariable masteryBaseDescription_IntVar;
    public UnityEngine.Localization.Components.LocalizeStringEvent masteryUpgradeDescriptionLSE;
    public UnityEngine.Localization.SmartFormat.PersistentVariables.IntVariable masteryUpgradeDescription_IntVar;

    private void Start()
    {
        masteryBaseDescriptionLSE.StringReference = ???;
        masteryUpgradeDescriptionLSE.StringReference = ???;

Thanks a lot for the help!

(I know there are similar posts about this on the forum but sadly I couldn’t find an answer to my issue)

@karl_jones would you be able to help on this by any chance ? Let me know if I can provide more detailed information, thanks! :slight_smile:

Hey,
Sorry, I have been busy the last few weeks and missed your message.
The LocalizedString is available through the StringReference property.

So something like this

masteryBaseDescriptionLSE.StringReference.SetReference("table", "entry");

Using SetReference

No worries, thanks a lot for your quick & efficient solution! Works like a charm :slight_smile: