Skip to content

Post-sync hooks

Run your own code after a sync finishes β€” validation, custom imports, extra generation.

All documentation β€” Extending
On this page

Mark a static method [TaleShardSyncComplete] and the plugin calls it after a sync completes: after the last file is written, after media is downloaded, and after assets are refreshed.

SyncReport.cs
using TaleShard.CodeGen.CodeGen;
using UnityEditor;
using UnityEngine;
namespace TaleShard.Docs.Samples
{
public static class SyncReport
{
// Must be static and take no parameters, or the plugin will not call it.
[TaleShardSyncComplete]
public static void OnSyncComplete()
{
Debug.Log("TaleShard sync finished.");
// Only for what YOU wrote β€” the sync already refreshed what it wrote.
AssetDatabase.Refresh();
}
}
}

That is the first moment your own code can see a complete synced project, which is what makes it the right place for validation and for anything that has to read generated output.

The contract

  • The method must be static and take no parameters. The plugin finds it by reflection, and the two ways of getting that wrong fail differently. A method that is not static is never found at all, so nothing runs and nothing is reported β€” check that first when a hook seems not to fire. A static method that declares parameters is found and called with none, which throws; the plugin catches it and logs [TaleShard] Sync callback <Type>.<Method> failed: …, so look in the console before assuming silence.
  • It runs in the editor, never in a build. Anything you do here is author-time work.
  • Several hooks may exist. Do not rely on the order they run in; if two must happen in sequence, one hook calling both is the way to say so.

What to use it for

Validation. Read the generated tree and refuse content that will not work in your game β€” a character with no portrait, a board with no entry, a command your project never implemented. A message in the console at sync time is enormously cheaper than the same discovery in play testing.

Custom imports. Post-process what the sync brought in: set import settings on synced textures, build an atlas, register addresses.

Extra generation. Emit a file of your own derived from the generated one. If instead you want to change what the plugin itself emits, that is a custom generator rather than a hook, and it runs at a different point.

Refreshing assets

Calling the asset database’s refresh at the end of a hook is usually right when you have written files yourself. It is already called by the sync before your hook runs, so you only need it for what you added.

Written for
Advanced integrators
Last updated