Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

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:
    657
    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,410
    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:
    657
    Works like a charm, thanks a lot :D
     
    karl_jones likes this.