How do you use Localization with Tooltips?

Hi all,
I searched the forum and didn’t find information about Localizations and Tooltips.

I have a very simple tooltip set up, but I cannot figure out how/where to add the Localize String Event.

If someone knows how to achieve this le me know…or if this question has already been answered, please forward me to the proper thread.

7478615--919652--upload_2021-9-7_13-12-44.png

It looks like you want to change a LocalizedStrings StringReference using a UnityEvent. We dont have a way to do this out of the box although it should be simple to support so ill add a task for us to add support in the future.
For now you can create a simple script to do it:

using UnityEngine;
using UnityEngine.Localization.Components;

public class ChangeString : MonoBehaviour
{
    public LocalizeStringEvent localizedStringEvent;

    public void ChangeStringEntry(string keyName)
    {
        localizedStringEvent.StringReference.TableEntryReference = keyName;
    }
}

Add this to your text

Now in your UnityEvent call the script and use the Key name as the text.

That should be all you need


I seem to have all the pieces in the right place, yet it’s not working.

Also note : They are Two event triggers - Pointer Down and Pointer Up. So in theory I would need two Localize String Event component on the same item right?

My present result : unity tooltips display BlackBreadDown and BlackBreadUp, instead of the aaa, bbb, CCC, DDD that are in the localization table.

No you should only need 1 localize string component. You have 2 different values in the set table entry callback.
In the onpointer events you call the change string script and set the table entry

Sadly, it’s not working.
Instead of displaying either aaa or bbb, it displays the Key name in the game UI tooltip.

Here is my setup.

Not sure why it’s not working.
Are their any plans to support tooltips - out of the box? - I’m guessing it’s a must in any localization package since tooltips are is many games.

Event Trigger → PointerUp ->Set ChangeString.ChangeStringEntry NOT “Text.text”

1 Like

You need to hook up the events to call the Change String class instead of Text

I see now! thanks to both of you! Your combined contribution pointed me to the proper setup.
7480970--919958--upload_2021-9-8_10-18-26.png

Yet, they still remain an issue. It’s not giving the same behavior as the tooltip.

Here are three image.
1.The inventory is empty and have it’s own Localization text.
2. The item is revealed. issue 1 : It now displays the Pointer Down text.
3. when you Pointer Down on the item, it displays the Pointer UP text.

Now, after this sequence, the behavior is then resolved. Meaning, after step 3, if I press again, I will get the proper Pointer Down and Pointer Up text.

Set LocalizedStringEvent->StringReference-> Set None(String)

1 Like

(sorry for the delay ) Setting the StringReference to Set None did not fix ths issue. With that setting, the tooltips no longer appear at all.

Can you share an example project of your problem so I can better understand it?

That sounds like a very good idea ! I’ll get this done soon.

1 Like

Preparing a scene I found out what I was doing wrong. The string reference was set to my Pointer Down text.
If I set my String Reference to my Pointer Up text, I get the behavior which I was looking for.

Thanks for the script and the support! Now to implement this on 30 game objects !

1 Like