Search Unity

Manual Keyframe Button/Script

Discussion in 'Timeline' started by ajsmith22, Jul 13, 2017.

  1. ajsmith22

    ajsmith22

    Joined:
    Jun 20, 2015
    Posts:
    9
    One of the features that I'm really surprised is missing is the ability to manually create a keyframe using a button or hotkey, or even a simple method that adds a keyframe to a track. Currently the only way to add a keyframe to a recorded gameobject is to hit the 'Record' button then move it in the scene view. Moving it via script doesn't even trigger a keyframe in Record mode.

    Does anyone know any way to add keyframe to an Animation Clip on the Timeline manually?
     
  2. thierry_unity

    thierry_unity

    Joined:
    Jun 10, 2015
    Posts:
    187
    Hi @ajsmith22
    There is actually a way to do it,
    when in record mode, right click on the property you want to record through the inspector window.
    2017-07-13_14-50-28.png
     
    sergio_gn likes this.
  3. ajsmith22

    ajsmith22

    Joined:
    Jun 20, 2015
    Posts:
    9
    Nice, that is somewhat helpful!

    Is that method accessible through script to make a hotkey out of it, or call it from another function by any chance?

    Also, is there a way to toggle Record Mode for a track via script ?
     
  4. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    No, the recording isn't available via script, and there are no hotkeys yet for adding a key.

    What you could do via script is create an animation clip using the AnimationUtility class and add it to an animation track.
     
  5. ajsmith22

    ajsmith22

    Joined:
    Jun 20, 2015
    Posts:
    9
    That does help somewhat! I had tried using imported clips before and it wouldn't let me record over them, but something I'm able to do is "Convert To Clip Track" once I've recorded on a track, and then from there I'm able to access the clip, as well as record onto it.
     
  6. heino_unity618

    heino_unity618

    Joined:
    Jul 2, 2018
    Posts:
    1
    Sorry for reviving such an old topic, but just wanted to know if the "Add Key" functionality still isn't available through scripts?
    I've been making a custom transform inspector with some added functionality, which works great for the most parts, but is struggling when it comes to animating transform paramters in timelines, because if the reasons explained above. It'd be great if I could have the "Add Key" functionality available through scripts, so I could call it when needed.
     
  7. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    A change just landed (targeting 2019.1) that exposes all the animation clips used by timeline (animation clips, tracks, playable clips and tracks). Exposure to the animation clips lets you modify them as you see fit (add key, add curve, etc...).

    Unfortunately it's not a back-portable change, so it's not really available in 2018.3, although there are workarounds using SerializedProperty (e.g. TrackAsset.m_AnimClip is the animation clip for infinite tracks).
     
  8. ghtx1138

    ghtx1138

    Joined:
    Dec 11, 2017
    Posts:
    114
  9. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    No, custom curves are exposed. I answered the question there. What you are doing should work just fine. Custom curves don't have the same limitations as recorded animations on animation tracks.