Search Unity

How to get a nice editor for TableReference?

Discussion in 'Localization Tools' started by 5argon, Sep 24, 2021.

  1. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    I have a table with item names. Each item has key, so to inspect the item and display localized name I must change the key of string reference in code (StringEvent.StringReference.TableEntryReference = "...")

    However I would also like to switch the "Table Collection" (StringTableCollection) in the C# code as well because they are categorized into multiple tables and you may not find a particular key in one table. This area must remains None until in the runtime.

    upload_2021-9-24_6-54-36.png

    I tried declaring an array of `TableReference` and I see in the code documentation that it includes editor functionality, however it does not have a drop down picker like it was in the string reference. Am I missing something to activate the editor? (e.g. so after selecting a table, it turns into GUID format)

    Code (CSharp):
    1. [SerializeField] private TableReference[] tableRefs;
    upload_2021-9-24_7-1-12.png
     

    Attached Files:

  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Are you using Odin? There seems to be an issue when using it that prevents the localized string from being drawn correctly.
     
  3. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    No, also in a fresh 2020.3.17f1 Unity project.
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    oh wait they are TableReference, TableReference does not have a drawer.
    Try using LocalizedStringTable instead. This does have a drawer to select the table.
     
    5argon likes this.
  5. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    It works! Thank you!

    Just in case, if I would like to ensure some tables loaded to the client before encountering the terms for real, is calling GetTableAsync() on this `LocalizedStringTable`, yield waiting on the AsyncOperation, and then ignore the result a correct approach to preload?
     
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Yeah that's fine although you should probably call Addressables.Aquire on the returned operation so that it doesn't get released and then call release when you don't need it anymore
     
  7. anaissalla

    anaissalla

    Joined:
    Jul 25, 2021
    Posts:
    3
    Hi! I have a custom serializable class with a "public LocalizedStringTable table". The drawer shows up correctly but I can't seem to choose any table (it does not even highlight any option and when I click on it, the drawer closes).
    upload_2023-3-14_22-19-22.png

    Is this a bug?

    This piece of code works
    Code (CSharp):
    1. public LocalizedStringTable table = new LocalizedStringTable { TableReference = "TestConvo" };
    but I want to be able to set it from the inspector.
    I tried setting the Table Reference with a string variable but it does not work :( What am I missing?
     
  8. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    What version of unity are you using?
    Do you have any plugins that may be interfering with the editor?
    Can you upgrade the package to 1.4.3? You may need to manually edit the manifest.json file in the packages folder if it's not visible.
     
  9. anaissalla

    anaissalla

    Joined:
    Jul 25, 2021
    Posts:
    3
    I was using Unity 2022.2.2f1 & package version 1.3.2.
    I have already upgraded to 1.4.3 but the problem still persists.

    I have also tried to create the same variable on a different script (monobehaviour) and it does work as intended in that one
     
  10. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Can you update to the latest version of 2022.2?
    If that's still not working then we would need a bug report.
     
  11. anaissalla

    anaissalla

    Joined:
    Jul 25, 2021
    Posts:
    3
    Took me a while but updating to 2022.2.10 fixed it! Thank you so much for the quick replies, I was losing my mind
     
    karl_jones likes this.