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

LocalizeSpriteEvent assigned key in inspector come back as empty string

Discussion in 'Localization Tools' started by cathode26, Nov 23, 2021.

  1. cathode26

    cathode26

    Joined:
    Jul 21, 2011
    Posts:
    27
    LocalizeSpriteEvent localizeSpriteEvent = GetComponent<LocalizeSpriteEvent>();
    string key = localizeSpriteEvent.AssetReference.TableEntryReference.Key;

    This key will be empty.
    How can I get the key?
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,845
    The asset reference can either be a Key or KeyId. If it's the Id then you can fetch the entry Which contains everything.
    LocalizationSettings.StringDatabase.GetTableEntry(localizeSpriteEvent.AssetReference.TableReference, localizespriteevent.assetreference.tableentryreference)
     
  3. Stephanommg

    Stephanommg

    Joined:
    Aug 18, 2014
    Posts:
    72
    In my case, I have a LocalizedString called nameID which works properly when calling nameID.GetLocalizedString(). However, if I access nameID.TableEntryReference it returns an empty string. Why?

    I really need to get the entry id string, not the translated value.
     
  4. Stephanommg

    Stephanommg

    Joined:
    Aug 18, 2014
    Posts:
    72
    O
    Ok, I solved it by using nameID.TableEntryReference.ResolveKeyName
     
    karl_jones likes this.