- Home /
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?
Answer by Ben Blaut · Apr 26, 2013 at 05:46 PM
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);
AssetDatabase.SaveAssets();
Your answer
Follow this Question
Related Questions
How can I reassign animation curves to play on a child object (instead of through parent)? 1 Answer
Create animation that allow picture to come in one by one 1 Answer
Can't Animate 0 Answers
Animation Help Needed (Method Not Found) 2 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers