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

Commit localization tables changes manually / without closing and re-opening the editor?

Discussion in 'Localization Tools' started by R42_Leon, Jun 29, 2020.

  1. R42_Leon

    R42_Leon

    Joined:
    Feb 24, 2016
    Posts:
    25
    Hi all, I noticed that the behaviour of table collections seems to be to store the changes to tables assets when the editor is closed, rather than on the actual table's entry change. I can see this by keeping an eye on the changed files in my version control software - When changing the entries on the table I can see the changes in the Unity Editor, and the game reflects those changes as well, but no changes are marked in version control. Then, when I close the Unity Editor, the .asset file for the relevant tables are updated with all the changes.

    Is there a way to commit the changes to disk manually (similar to the "save" button on the shadergraph window toolbar, for example), either via editor windows or scripting?

    As a side effect of this, I have a simple script that parses the content of a .csv file into some string tables - I can see that it works fine from the tables editor and when testing the game, but this doesn't seem to "trigger" the behaviour that marks a table as "dirty" and when I close the editor none of those changes are saved to the .asset file. If I open that table in the table editor, and then change some values manually, then the edits are "registered" and stored to disk when the editor closes.
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
    Hi.
    To write asset changes to disk do File/Save Project.
    You can also do it in script with AssetDatabase.SaveProject()
    If you are making changes to the assets then you need to set the asset dirty using EditorUtility.SetDirty. do this to each table you change and also to the shared table data asset.
     
    R42_Leon likes this.
  3. R42_Leon

    R42_Leon

    Joined:
    Feb 24, 2016
    Posts:
    25
    Thanks, that worked like a charm. On Unity 2019.4, the methods seems to be called `AssetDatabase.SaveAssets()`

    There's another inconsequential issue I'm having which might have to do with similar reasons - I have a ScriptableObject with a few public LocalizedStrings in it, and a function that updates those strings by looping over a tables collection and query the keys that match a specific criteria - I am updating the LocalizedStrings by calling `SetReference(Collection.TableCollectionNameReference, entry.KeyId)`. The string is updated just fine, but the serialized LocalizedStrings fields in the inspector do not show the updated string until I deselect the ScriptableObject and select it again (or even hit Ctrl-Z), which seems to "refresh" the fields.

    I though calling `EditorUtility.SetDirty` on the ScriptableObject would do the trick, but it doesn't. It's not a big deal since the strings are actually updated correctly, but if you can think of any ways to address this, I'm all ears!

    Cheers
    L
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,846
    We have some caching in the LocalizedStringProperty drawer so that may be why it's not updating. Could you file a bug report? I can see if there's something we can do.
     
    R42_Leon likes this.