So I’m becoming quite fond of using an animation curve as a property for various scripts, but I was wondering if its possible to copy and paste an animation curve between properties? To me the animation curve editor (the one used for a property in a script) seems to be quite limiting - I cant work out how to type in a value for the point, or how to copy and paste. However, in C# you can obtain information about all the keyframes and their tangents etc, so if worse comes to worse I could always make a script that does the copy and paste manually. But yeah, thought I’d just post a question incase i’m missing something obvious ![]()
Unforunately (to the best of my knowledge) this is impossible.
Workaround: Create a prefab, add your script, add your desired animation curve, then copy that prefab into whatever and it will retain this curve. Hope this helps.
You can read and write animationcurve data using asset postprocessor scripts, manipulating keyframes, etc. however you want.
Its possible to open the .prefab file with a plain text editor and copy/paste the curve data across to another prefab. Careful not to mess up the file and you’re ok.
May I suggest an other approach more coder-friendly : if you have to copy from one field to another specific, code a method with access via ContextMenu. I use that way everytime I have something really simple to do in code but annoying to do with the Inspector.
I ran today into the same problem. All of the above solutions didnt quite work out. What i ended up doing is coding a small Editor Window to help me with copy pasting of AnimationCurves between different Animation Clips.
Code Can be found here:
Usage:
Create a c# class in an Editor Folder and paste the code there
Once done go to Unity Click on Window/Animation Copier
A Window will pop up that can be docked anywhere you like
To Copy or Remove just check the stuff you want to copy and press the copy button
(Be aware that every child of one Object checked will be copied as well)
short example
Hope someone finds it useful.
KeySam
It doesn’t work for me. Would be very handy though.
If anyone needs to copy an animation curve, you can use the presets.
In the animation curve window of the animation curve you want to copy, click the option cog in the lower left (next to the pre-existing presets). Then click the “new” button. You can now use this new presets to paste the animation curve.
Not exactly a copy-paste per se, but get the job done!
You just have to open your prefab file in a code editor and copy/past the animation curve values in your other prefab file with your other script on. Not very friendly but works perfectly.
