Localizing Toggle with Sprite Swap

This is a two part problem. First of all I have a Toggle which has a target graphic with an Image that has a Localize Sprite Event. Now when I start the game it displays the correct sprite for the selected locale. When I hover over it, it displays the hover sprite and on mouse leave it goes back to the graphic that is the Source Image of the background, not the swapped sprite for the current locale.

The other question is, how do I swap the sprite in the toggle for the sprite swap options? There is no option to select any of them in the localization menus.

Hi,

Could you share some screenshots of how each GameObject on the Toggle is configured?

8767159--1189072--toggle2.png

The configuration for the toggle.

Background localization. Like I said works at game start but doesn’t make it through hover.

Checkmakrs works fine. Just adding for completionist.

Im not able to reproduce this issue. What version of the package are you using? The latest is 1.4.3. You may need to edit the manifest.json file in the Packages folder to manually update.
If the issue is still reproducing after using 1.4.3 then you could share a simple example project that shows the issue and also confirm what version of Unity you are using?

Ok this might be the issue. I just installed it from the package manager and that’s 1.0.5 which seems very far behind. I’ll update and report back.

1 Like

Ok updated and now it doesn’t show the correct sprite at start. It does when I switch to de and back to en. The hover problem is also still the same. Gonna make n example project after lunch.

1 Like

Hope I included the correct files. Unity version is 2021.3.1f1

It shows the same behavior. Correct sprite shown when it starts, default locale en. After hover it doesn’t get back to the en sprite.

Also, assuming we get to fix this, can you advise on how to localize the sprite swap for the hover graphics?

8767315–1189108–Toggle_example.zip (136 KB)

I see the problem. It was actually visible in your screenshots, I just missed it :frowning:
A sprite has 2 images. sprite and overrideSprite. The sprite is the base value that is always used when there is no override, this is the value we want to localize. The overrideSprite is what gets set by the Toggle.
So in your scene, the LocalizeStringEvent changes the overrideSprite, the Toggle then changes it and when it’s finished it sets it to null so that it reverts to the default. You just need to change the LocalizedSpriteEvent so that it sets the value of the sprite and not overrideSprite

Did you configure the LocalizedSpriteEvent yourself? If you right-click the Image component you will see an option called Localize that will add and configure a LocalizeSpriteEvent for you, it will use the sprite field by default.

I added the localize component myself. The right click option is great and it also answers my question on how to update the hover sprite. Thanks alot for the fast answers.

1 Like