YarnSpinnerTool / YarnSpinner-Unity

The official Unity integration for Yarn Spinner, the friendly dialogue tool.
MIT License
491 stars 85 forks source link

Unity Localized Line Provider does not save changes to dialog line table #240

Closed samanabo closed 1 year ago

samanabo commented 1 year ago

What is the current behavior? Using unity localization, when a project file is imported it will automatically update the unity strings table to include new entries and metadata from the project's scripts. However, the table and metadata are not marked as dirty in the editor and changes are not saved.

Please provide the steps to reproduce, and if possible a minimal demo of the problem: Create a project using unity localization. Import a yarn project and script with lines. Edit the strings table, and note the current saved data. Modify the yarn script, then build the game. Observe there are no saved changes to the strings table. This can cause null reference exceptions in a build due to missing lines and metadata entries.

What is the expected behavior? When a project is imported and string tables are updated, these changes should saved and commited to the strings table.

Unity recommends calling EditorUtility.SetDirty on the table and the SharedData for the table: https://docs.unity3d.com/Packages/com.unity.localization@1.4/manual/Scripting.html#editor https://forum.unity.com/threads/localization-how-to-set-strings-via-scripting.1349855/#post-8521172

EditorUtility.SetDirty(table);
EditorUtility.SetDirty(table.SharedData);

This could be done around line 520 of YarnProjectImporter.

Please tell us about your environment:

desplesda commented 1 year ago

Thank you! Fixed in the above commit. I also went ahead and set the asset table collection as dirty when AddAssetsToAssetTableCollectionWizard makes changes to it.