Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Comparing Table Entry References

Discussion in 'Localization Tools' started by maikkanerva, Oct 31, 2023.

  1. maikkanerva

    maikkanerva

    Joined:
    Dec 14, 2018
    Posts:
    27
    Hi,

    Let's say we have object A and B that both have a localized string. I want to compare these objects, and they are considered "same" if they have matching localization entries.

    I'm trying to compare LocalizedString.TableEntryReference.KeyId and Key.
    However, sometimes the other one as Key (the string) defined and KeyId being 0 and the other has it the other way around.

    Why is this? It doesn't seem to be consistent as this started now causing problems for me suddenly as things aren't considered the same suddenly.
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,147
  3. maikkanerva

    maikkanerva

    Joined:
    Dec 14, 2018
    Posts:
    27
    Thanks for the reply.

    Unfortunately it's not editor script. More like comparing two abilities to see if they are the "same" (by just the localization reference).

    What worked for now was to just use GetLocalizedString() and and compare the string values, as in my case they are unique.
     
    karl_jones likes this.
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,147
    You could first check the ReferenceType, if it matches then you are safe to compare the 2 Keys or Key Ids, if they are not the same then fallback to checking the entries.
     
    maikkanerva likes this.