Search Unity

Question Change the String Reference in Runtime

Discussion in 'Localization Tools' started by FidelAraguzLara, Apr 4, 2023.

  1. FidelAraguzLara

    FidelAraguzLara

    Joined:
    Oct 14, 2021
    Posts:
    4
    Hi, i already read the documentation but i didn´t realize how to change the String Reference in Runtie, im talking about this one.
    upload_2023-4-4_14-50-38.png

    I want to set the table key to a google sheet key, i tried with smart strings but i didn´t get it to work, i am new to the package so i am sorry if this is simple to do :(

    I already connected my google sheet to unity thanks to the documentation.

    upload_2023-4-4_15-7-10.png

    This is an scriptable object, the info is hardcoded, but i want to indicate the key name of my google sheets so unity automatically take the data of that key.

    upload_2023-4-4_15-10-42.png

    Something like this if i type or reference of something like that, "play", then unity is gonna take the data of the key "play" from my google sheet for the different locales i have in it.

    Is there any possible way to make it work?
     

    Attached Files:

  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,279
    Google sheets support is editor only, you can't pull the data in a player build.
    If you want to change the LocalizedStringEvent reference at runtime you can do it with
    GetComponent<LocalizedStringEvent>().StringReference.SetReference()

    You could also add a LocalizedString to your scriptable object as a field instead of using a string, then you can set it up in the inspector.
     
    FidelAraguzLara likes this.
  3. FidelAraguzLara

    FidelAraguzLara

    Joined:
    Oct 14, 2021
    Posts:
    4
    Thanks a lot, let me try this out and see if it works.
     
    karl_jones likes this.
  4. FidelAraguzLara

    FidelAraguzLara

    Joined:
    Oct 14, 2021
    Posts:
    4
    After trying a lot it just worked fine :D, thank you a lot
     
    karl_jones likes this.