Search Unity

How to get the LocalizedString Key-Name in the Editor?

Discussion in 'Localization Tools' started by John_Leorid, Oct 20, 2020.

  1. John_Leorid

    John_Leorid

    Joined:
    Nov 5, 2012
    Posts:
    650
    I have made a cool localized singpost and I'd need to get any kind of string from the LocalizedString field in the editor.
    GetLocalizedString() does not work and the LocalizedReferencePropertyDrawer is way to complicated.
    All I need is some kind of string, key-name would be fine.
    LocalizedString.ToString() just yields some numbers - how to get the Key-Name in Editor (not at runtime)?

    Signpost looks like this:

    upload_2020-10-20_14-15-58.png

    To rotate the arrows properly, it is required to know which key is referenced.
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,281
    Hi,

    Editor support is something that will come in the future.
    You can convert the Id values into names in the Editor like so:

    Code (csharp):
    1.  
    2. var collection = LocalizationEditorSettings.GetStringTableCollection(myTableReference);
    3. var entry = collection.SharedData.GetEntryFromReference(myTableEntryReference);
    4. Debug.Log($"{collection.TableCollectionName} - {entry.Key}");
    We also plan to provide some Editor ToString overrides to the references to convert to names in the future.
     
    Last edited: Oct 20, 2020
    Draag likes this.
  3. John_Leorid

    John_Leorid

    Joined:
    Nov 5, 2012
    Posts:
    650
    Works like a charm, thanks a lot :D
     
    karl_jones likes this.