Run a function in editor post save?

So there’s a PreSave function for UObjects, which is great, but I’m looking for something to hook into *after *specific assets have been saved. Is there a global delegate or something I can use?

I basically want to pop a dialog and prompt the user to save additional, related assets.

You can either override Serialize() method or subscribe to package event:

https://docs.unrealengine.com/en-US/…ved/index.html

The package saved event is helpful but I can’t trigger save of additional assets from there, it’s detecting re-entrance and aborting. How can I defer the task until saving is complete?

I’ve tried using a GameThread AsyncTask, but that still runs during the initial save.

OK what worked for me was a combination of the package saved event and the asset registry’s OnAssetUpdated, which runs (several times) after all the packages have finished saving. I collect up the packages I want to save in the package saved event, then trigger the followup save dialog in OnAssetUpdated.

A simple thing I do to save custom script assets on “Magic Node” plugin is this:



virtual void Serialize(FArchive & Ar) override;

void Serialize(FArchive & Ar) {

    if (Ar.IsSaving())
    {
        //export string from editor Widget to a text file...
    }
    else      {
        // read script from text file...
    }

    super::Serialize(Ar);
}