Empty animation clips when copying to Prefab

There seems to be many other occurences of this problem, but there hasn’t been any response or fix yet. In my case, I’m using the AssetPostprocessor (specifically OnPostProcessAllAssets) to create a prefab of an imported FBX model as it comes in. I am able to instantiate a GameObject from the FBX, make some modifications to the animation curves, then reattach them to the instantiated object. However, when I try to copy this instantiated object into a prefab, the clips disappear. The clip array is still sized correctly, but everything is gone. It doesn’t matter if I do this by drag-and-drop or through PrefabUtility.ReplacePrefab. Why is this happening?

The problem here was that the clips were not added to the Asset Database. Creating a new clip and putting it on an object in the scene lets it work in the scene. To add it to a prefab, you have to add it to the database. These lines of code fixed it for me:

AssetDatabase.CreateAsset(newClip, assetPath);