Search Unity

Resolved Delete all table entries

Discussion in 'Localization Tools' started by JulianMC, May 5, 2021.

  1. JulianMC

    JulianMC

    Joined:
    Dec 30, 2019
    Posts:
    26
    Hi again, I was wondering if there was a way to delete all data inside the tables via Script.
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Yes get the table and then call Clear on the Entries property. Do the same for the Shared table data.
    I'm not at my desk so I can't post a code snippet at the moment.
     
  3. JulianMC

    JulianMC

    Joined:
    Dec 30, 2019
    Posts:
    26
    I tried but this only erase the texte and not the key, what I want is to delete all the data of the collection, like if it was a new one
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    The keys are part of the SharedTableData.
    Delete the entries from that as well.
    You can get to it from the collection.
     
  5. JulianMC

    JulianMC

    Joined:
    Dec 30, 2019
    Posts:
    26
    LocalizationEditorSettings.GetCollectionForSharedTableData(collection.SharedData).RemoveEntry("entryName");

    you mean like this?

    or there is another way to delete everything like when doing Clear() ?
     
    Last edited: May 5, 2021
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Getting the Entries property and calling Clear should do it.

    collection.SharedData.Entries.Clear
     
    JulianMC likes this.
  7. JulianMC

    JulianMC

    Joined:
    Dec 30, 2019
    Posts:
    26
    oh ok, yes perfect, thank you very much!
     
    karl_jones likes this.
  8. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    You may also need to set the assets dirty if the changes are not saved. EditorUtility.SetDirty.on the tables and SharedTabledata
     
    JulianMC likes this.
  9. JulianMC

    JulianMC

    Joined:
    Dec 30, 2019
    Posts:
    26
    ok, thank you!
     
    karl_jones likes this.