Event or Callback for when Files are moved.

Is there an event or callback in Unity for when a file is moved? I want to pop up a little dialog box in the editor when a file is moved into the Resources folder and I was hoping i could just check for a Unity event or register for a Unity callback

Try AssetModificationProcessor.OnWillMoveAsset. The example code in that docs page should be enough to get you started. Note that just like what you see in the example code, you only need to implement OnWillMoveAsset and the base class needs to be UnityEditor.AssetModificationProcessor (don’t remove the “UnityEditor.”). No callback/event registration is necessary.

A few tips:

  1. This gets called for any file move operation in the Project window. You’ll have to use some string methods to check the asset being moved, like destinationPath.Contains("/Resources/") to check if something is being moved to a Resources folder, stuff like that.

  2. This also gets called when an asset is renamed. The path in both strings will be the same, just the filename will be different.