Specifically this is referring to the Google Sheets extension, but it could be useful in other places.
When having many people working on the same sheet it becomes error prone to coordinate pulls/pushes. What I currently do is have a metadata column which stores the UTC timestamp of last modification in both the editor and in the sheet via appscript. When pulling, I first store in a temporary table collection (which is itself just a blank table collection ensuring same column order and locales as all the others), then compare the change times, missing rows etc and generate a correct result into the target tables and push that back to Google.
Obviously this isn’t an ideal solution (although for now it works just fine). It would be useful to be able to have custom columns that can deny/accept changes per-row by way of return (accept/skip/delete etc) and provide a reference to the existing TableEntry if available. It’d probably require an appscript to do this selectively/efficiently for the Push, but for Pulling I imagine it is not too taxing.
Just to lump in a couple bug reports in 1.0.0-pre.9 (apologies I don’t want to spam the forum and I’m not sure where to submit bugs):
Push/PullMetadata currently does not get called for LocaleMetadataColumns. Not a huge issue either as the same functionality can be accessed by just using Push/PullCellData.
LocalizationEditorSettings.EditorEvents.TableEntryAdded does not get called when adding a string table entry.
String table editor has a panic attack if you delete a string table entry while viewing its metadata.
I think this may be fixed in the next release 1.0.0-pre.10. If its not then could you file a bug report through the bug reporter tool, please? https://unity3d.com/unity/qa/bug-reporting
We do have a bug for this at the moment. A lot of the Editor events were intended just for editor usage and so don’t get called from runtime API. We plan to look into this.
What do you mean?
Thanks. Syncing is hard
We do have a new feature in the next release that lets you mark an entry with metadata ExcludeEntryFromExport. This is mainly for preventing certain entries from being exported, e.g NDA stuff. Maybe we can add improve on the interface to allow it to be more dynamic. There is additional info available in the GoogleAPI that may help with syncing. Ill create a task for us to look further into it in the future.
Yep, I mean in the editor If I add a string entry through the string table editor, the callback doesn’t seem to get triggered. The code below triggers only on string modification.
namespace __.__.Editor
{
[InitializeOnLoad]
public class LocalizationHooks
{
static LocalizationHooks()
{
LocalizationEditorSettings.EditorEvents.TableEntryAdded += TableEntryAdded;
LocalizationEditorSettings.EditorEvents.TableEntryModified += TableEntryModified;
}
static void TableEntryAdded(LocalizationTableCollection collection, SharedTableData.SharedTableEntry entry)
{
LastEditedTimeMetadata md = new LastEditedTimeMetadata();
entry.Metadata.AddMetadata(md);
md.lastModifiedTimeUTC = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
}
static void TableEntryModified(SharedTableData.SharedTableEntry entry)
{
LastEditedTimeMetadata md = entry.Metadata.GetMetadata<LastEditedTimeMetadata>();
if (md == null)
{
md = new LastEditedTimeMetadata();
entry.Metadata.AddMetadata(md);
}
md.lastModifiedTimeUTC = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
// TODO update this to set only the active table (this isn't easily exposed rn)
foreach (var v in LocalizationEditorSettings.GetStringTableCollections())
{
EditorUtility.SetDirty(v.SharedData);
}
}
}
}
Specifically it doesn’t stop trying to view the metadata, so every refresh of the UI causes an exception. It actually crashed the entire editor when first reproing this to copy the console: Add entry to string table, type in some random data, don’t ctrl-s, remove the entry → crash. Removing a previous entry doesn’t cause the same issue, nor if I ctrl-s before removing.
This metadata is available currently in pre.9, however the editor code seems to completely remove it from the export table, rather than just keeping the current value - I didn’t check much further but it might also be the case that this would cause issues with “Remove Missing Pull Keys” which we definitely want to use while syncing, my design team have a habit of creating entries for stuff and deciding they don’t need it…
Syncing is definitely an annoying problem, but being able to solve it in a different way than locking a resource so it can only be changed by one person at a time is certainly a worse problem than having to do a little extra work for me to do some Google syncing at the moment