Create new entry via script in editor - does not survive editor restart

Hello,

We are working on simple dialogue system with editor support. We’re using following code to create entries in UnityEditor programmatically:

LocalizationSettings.StringDatabase.GetTable(ourTable).AddEntry(newKey, "");

var prop = so.FindProperty("Text");

prop.FindPropertyRelative("m_TableReference").FindPropertyRelative("m_TableCollectionName").stringValue = ourTable;
prop.FindPropertyRelative("m_TableEntryReference").FindPropertyRelative("m_Key").stringValue = newKey;

And to edit them:

if (newText != text)
{
    LocalizationSettings.StringDatabase.GetTable(_node.Text.TableReference).GetEntryFromReference(_node.Text.TableEntryReference).Value = newText;               
}

And this works correctly while editor is open. Closing the Unity Editor and re-oppening it discards all changes made by above code.

I am almost sure that I miss a step to save our changes to addressables - but poking around docs, I could not find the relevent command.

Can you point me in the right direction?

Ah yes. When you make a change to the table you need to set it dirty with EditorUtility.SetDirty
You will need to set the table and the shared table data dirty

so

EditorUtility.SetDirty(ourTable);
EditorUtility.SetDirty(ourTable.SharedData);

We will try and automate this in the future but for now you need to manually set them dirty.

Thank you for a very quick response :slight_smile:

Confirmed - it is working now.

Just one more question - is there any way to set this field from a script?

7370864--898568--test.png

Yeah its the same as in the player.

LocalizationSettings.SelectedLocale

Thanks again :slight_smile: