Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug SmartString checkbox automatically un-checks itself

Discussion in 'Localization Tools' started by AbsurdAndy, Jul 31, 2023.

  1. AbsurdAndy

    AbsurdAndy

    Joined:
    Dec 6, 2019
    Posts:
    47
    I have a smartString, and when I check the box it immediately unchecks itself:

    Unity_vghcii613m.gif

    However, for non-smart-strings, the checkbox works fine:

    Unity_BMCfsE2qlp.gif

    This is in Unity 2023.1.4f1 with Localization 1.4.4.

    I wrote a script to attempt automating the checking of these boxes to work around this bug, but it is having no luck altering things as well.
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,820
    Hmm I have not seen this before.
    What's the difference between the 2 entries?
    How can I reproduce this issue locally?
     
  3. AbsurdAndy

    AbsurdAndy

    Joined:
    Dec 6, 2019
    Posts:
    47
    As far as I can tell the entries are very similar (they are right next to each other in the same table). I'm seeing this happen for any string that contains a brace; anything free-of-braces the checkbox works fine.

    I have a slimmed down sample project I can send you if that helps - it just contains the Loc table and demonstrates this behaviour. Let me know where I can send it if that is helpful.

    Meanwhile I have filed an official bug (and attached this same project to it) -- IN-49744
     
    karl_jones likes this.
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,820
    Thanks
    I can take a look at the project you attached to the bug.
     
  5. AbsurdAndy

    AbsurdAndy

    Joined:
    Dec 6, 2019
    Posts:
    47
    For future forum searches, it appears this has been "marked as fixed" for v1.5.0 of the localization package. I can't confirm as it isn't released yet. :)
     
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,820
    Yes, we have fixed it. Its a bug in how we detect if a string is marked as smart. We had a mix-up with metadata. Once the fix lands you should see the fields that won't set marked as smart because they were always set as smart, the system just wasn't detecting them.
    Here is a script that can fix the issue for you now.

    Code (csharp):
    1. [MenuItem("Test/Fix My Table")]
    2. public static void FixTable()
    3. {
    4.     var tables = LocalizationEditorSettings.GetStringTableCollection("MyTable");
    5.  
    6.     foreach (var table in tables.StringTables)
    7.     {
    8.         var smartFormatTag = table.GetMetadata<SmartFormatTag>();
    9.         if (smartFormatTag == null)
    10.             continue;
    11.  
    12.         foreach (var entry in table.Values)
    13.         {
    14.             if (entry.HasTagMetadata<SmartFormatTag>() && !entry.IsSmart)
    15.             {
    16.                 // Fix it
    17.                 entry.MetadataEntries.Add(smartFormatTag);
    18.             }
    19.         }
    20.  
    21.         EditorUtility.SetDirty(table);
    22.     }
    23. }
     
  7. AbsurdAndy

    AbsurdAndy

    Joined:
    Dec 6, 2019
    Posts:
    47
    That did the trick! Thanks!
     
    karl_jones likes this.