Search Unity

Resolved How do you set up LocalizedStrings in the editor?

Discussion in 'Localization Tools' started by _eternal, Nov 6, 2021.

  1. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    304
    I have a ScriptableObject with a few LocalizedString fields in it. Another script is supposed to access this SO and use its data to populate some text fields.

    Now, I set this up a few months ago and I thought it was working fine. Something in the serialization must have broken after updating the asset (I'm on 1.0.5 right now).



    This is what the serialized field looks like for me. The field is called "town".

    I can't make heads or tails of what I'm supposed to click on. The "key" sounds like it should be the Key string or KeyId int that we see in the StringTable. But what is the value supposed to be? If I select LocalizedString, it just leads to an infinite loop of nested key-value pairs. And if I select StringVariable, it asks for a string, which is not what I want - the whole point is for it to grab the correct string from the table at runtime, rather than a pre-defined string.

    Weirdly enough, though, I can see the values that I previously set up in this SO if I switch to Debug view.



    I can't tell if I'm misunderstanding how LocalizedString works, or if I encountered a serialization bug, or perhaps both. This SO actually works right now, but even though those values are visible in Debug view, they show as empty in the normal inspector view. If I create a new SO and use that instead, the game throws an error on load complaining about empty tables - so it seems that the original object was actually set up correctly, but I just can't edit it thanks to some kind of serialization trouble?

    I do have Odin Inspector in my project, but the asset comes with a serialization debugger that tells you whether a field is serialized by Odin or by Unity. It's saying that everything in this script is serialized by Unity, which makes sense because I didn't implement Odin at all in this scriptable object.
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Odin is breaking the inspector. You need to disable it for the localized string inspector.
     
  3. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    304
    Interesting, ok. Thanks. I'll follow up with them.
     
    karl_jones likes this.
  4. Tor-Vestergaard

    Tor-Vestergaard

    Joined:
    Mar 20, 2013
    Posts:
    188
    For what it's worth, I can report that as of 3.0.12 Odin now has dedicated support for the Unity.Localization package and should now correctly draw UnityEngine.LocalizedString, as well as serialize it if it is in Odin-serialized data. If there's any other issue with Odin and this package, please let us know about it as we now have a module set up to easily add further custom support :)
     
  5. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Awesome! Thanks for adding support.