How do I add animation events to an imported animation at editor time?

I’m trying to automate my animation events a little bit, we have a spreadsheet with frame counts for events to fire and I need to add them to hundreds of animations.
Unfortunately the 5.6 animation event system is really tedious to use for this job, so I’m trying to write a script to just put events on the frames i want. Problem is I can’t figure out how to add the events by code to an imported FBX animation. Does anyone have an example?

Check out:

You should be able to find AssetPostprocessor examples to suit; you’ll want to do something like this:

void OnPreprocessModel() // or OnPostprocessModel depending on your needs/the docs
{
  ModelImporter modelImporter = assetImporter as ModelImporter;
  addEventsToClips(spreadsheet, modelImporter.clipAnimations.events)
}
3 Likes