Welcome, Guest
Username: Password: Remember me

TOPIC: Blocker crash with fonts (it seems)

Blocker crash with fonts (it seems) 6 months 5 days ago #2767

  • Largelabs
  • Largelabs's Avatar
  • Offline
  • New Member
  • Posts: 3
  • Karma: 0
Hey,

I recently bought I2 Localization and yes, it's a great asset and a huge time saver. However..

I'm facing an issue right now and I haven't found any solution so far.
I created a font term and I added 3 translations for it :
French and English use the same font (same asset, same name). However, arabic needs to have a different font.
I'm applying these fonts as a secondary term on a Text component in Unity UI. I set pre-localize on Awake at true.

I play my game and everything works fine. Then, I stop the player, add a new term directly in the I2Languages prefab. A simple text. This step seems important in order to reproduce the bug, apparently it triggers it. I don't use this new term anywhere and I simply play the game again.

When I try to show a text that has the font as a secondary term, there is a crash :

ArgumentException: An element with the same key already exists in the dictionary.

This comes from the following function in LanguageSource :

public void UpdateAssetDictionary()
{
Assets.RemoveAll(x => x == null);
mAssetDictionary = Assets.ToDictionary(o=>o.name);
}


This bug happens systematically. I can't access the corrupted term in the prefab, the UI is broken. Therefore, I cannot delete it or change it. The only way I can get out of this is reimporting my spreadsheet that doesn't have the font term and quit unity (if I try to create the term again without quitting Unity, I get the crash immediately).

Also, this started happening after I changed my PC's language from French to English for some testing (but I don't know if there is any connexion)

Is there a way I can fix this ? or perhaps I've been doing something wrong without knowing and you could give me the best practice ? This is quite blocker.

Attachements : the logs in Editor Console Pro + the broken UI on the corrupted term

Many thanks,
Attachments:
Last Edit: 6 months 5 days ago by Largelabs.
The administrator has disabled public write access.

Blocker crash with fonts (it seems) 6 months 5 days ago #2768

  • Frank
  • Frank's Avatar
  • Offline
  • Administrator
  • Posts: 1112
  • Thank you received: 234
  • Karma: 68
Hi,
Thanks for reporting this issue.
It was happening because the Asset references were getting duplicated values. I added a fix to prevent this to happen in the first place.
Now, if you try adding an object that its already in the Assets tab or the References tab, it will skip it. There is also code around to remove duplicates if for some reason the list got corrupted.

I will be uploading v2.8.3a5 to the beta folder later today.
In the meantime, if you want to avoid the problem, changing the following line will prevent the crash (doesn't fix the duplicates, but will work fine)
Add "Distinct()" in these two places:

I2 Localization Latest\Assets\I2\Localization\Scripts\LanguageSource.cs line 279
        public void UpdateAssetDictionary()
        {
            Assets.RemoveAll(x => x == null);
            mAssetDictionary = Assets.Distinct().ToDictionary(o=>o.name);
        }

i2 localization latest\assets\i2\localization\scripts\localize.cs line 339
        public void UpdateAssetDictionary()
        {
            TranslatedObjects.RemoveAll(x => x == null);
            mAssetDictionary = TranslatedObjects.Distinct().ToDictionary(o => o.name);
        }

Hope that helps,
Frank
Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out
The administrator has disabled public write access.
The following user(s) said Thank You: Largelabs

Blocker crash with fonts (it seems) 6 months 5 days ago #2769

  • Largelabs
  • Largelabs's Avatar
  • Offline
  • New Member
  • Posts: 3
  • Karma: 0
Thank you for your reply. Will add that fix and will download your update when it goes live.

In the meantime, the bug stopped occuring. In my multiple and weird maneuvers, I probably did something that ended up cleaning the asset database from its duplicates.

Cheers,
The administrator has disabled public write access.
Time to create page: 0.148 seconds
Colors