Change String of LocalizationTable vía C#

Hi,

I want to modify an existing String Table.I’m referning the Locale in the editor, but when I execute the script this error shows:

Exception: Can not add new table. The same LocaleIdentifier is already in use.

 // Get the collection
            var collection = LocalizationEditorSettings.GetStringTableCollection("TestTable");

            // Add a new table
            var newTable = collection.AddNewTable(locale.Identifier) as StringTable;

            // Add a new entry to the table
            var entry = newTable.AddEntry("Hello", "Hola");

            // Add some metadata
            entry.AddMetadata(new Comment { CommentText = "This is a comment" });

            // We need to mark the table and shared table data entry as we have made changes
            EditorUtility.SetDirty(newTable);
            EditorUtility.SetDirty(newTable.SharedData);

How can we modify an existing StringTable? The only way is to create an asset of the String Table each time you want to modify a new Entry?

Thanks in advice,
Diego

You need to call GetTable, not AddTable.

That was straight, great system!
Thanks.

1 Like