Search Unity

AnimationCurve - Copy and paste

Discussion in 'Editor & General Support' started by Divide, Dec 31, 2010.

  1. Divide

    Divide

    Joined:
    Nov 10, 2010
    Posts:
    28
    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 :)
     
  2. Charles-Van-Norman

    Charles-Van-Norman

    Joined:
    Aug 10, 2010
    Posts:
    86
    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.
     
  3. goodhustle

    goodhustle

    Joined:
    Jun 4, 2009
    Posts:
    310
  4. standardcombo

    standardcombo

    Joined:
    Jun 28, 2012
    Posts:
    19
    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.
     
  5. Messu-Kilkain

    Messu-Kilkain

    Joined:
    Nov 2, 2012
    Posts:
    3
    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.
     
  6. AShim-3D

    AShim-3D

    Joined:
    Jul 13, 2012
    Posts:
    34
  7. KeySam

    KeySam

    Joined:
    Jan 25, 2013
    Posts:
    8
    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:

    http://pastebin.com/TMu6ShLZ

    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
    exampleAnimationCopier.png :

    Hope someone finds it useful.

    KeySam
     
    MoMonay likes this.
  8. pokst

    pokst

    Joined:
    Feb 14, 2016
    Posts:
    2
    It doesn't work for me. Would be very handy though.
     
  9. Isaleus

    Isaleus

    Joined:
    Sep 29, 2016
    Posts:
    4
    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!
     
  10. Basic50

    Basic50

    Joined:
    Dec 30, 2013
    Posts:
    5
    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.
     
    mdrunk likes this.