YarnProject reimport triggered while playing in Editor results in empty String Table being saved
What is the current behavior?
String table under yarn project file becomes empty when a yarn source script under the project file is modified and saved while the editor is in play mode

Please provide the steps to reproduce, and if possible a minimal demo of the problem: Setup:
- Open Unity's Preferences window, and under the
Generaltab, change the option forScriptChangesWhilePlayingtoRecompile And Continue Playing - Any scene, even an empty scene (doesn't have to have any YarnSpinner logic running)
- Create any yarn script file with test text, and create a corresponding yarn project that has the yarn script set as a source script
Repro:
- Start playing in editor with any scene
- Open yarn script in text editor, modify the script by adding/removing some lines, then save file in text editor
- Focus back to Unity (if the Unity preferences was set as above, this should trigger a reimport of the yarn project)
- Stop playing in editor
- Check the String table of the yarn project that includes the previously modified yarn script
- Result: String table is empty
What is the expected behavior?
- The string table under the yarn project is not empty, and reflects the latest yarn script changes
Please tell us about your environment:
- Yarn Spinner Version: 2.0.2
- Unity Version: 2020.3.26f1, 2019.4.15f1
Other information
- Not sure if this is the root cause, but when I was looking into the issue, it looked like the call to
Localization.AddLocalizedStringthat starts from line 340 ofYarnProjectImporter.OnImportAssetis resulting in the generated string table to be put into_runtimeStringTableinstead of_stringTable. - Also note that once out of play mode in the editor, doing anything that triggers the yarn project import (Reimporting yarn project, modifying and saving source script) resolves the issue
Please let me know if there's any more information you need. Thanks!
Thank you very much for filing this! This is a bug that I was trying to track down for some time, but I'd been totally failing to reproduce. The fix turned out to be very straightforward - as you suggested, the issue was that lines were being added to the runtime table because we were in play mode, but that's not the correct thing to do during an asset import.
Thanks again!