Add Keyframes in Timeline using a GUIEditor?

Animating a GameObject using a GUIEditor does not record keyframes.

  • I want to animate a GameObject using the new Timeline feature (in Unity 2017.2).
  • I have added the GameObject to the Timeline.
  • I press the GameObject track’s record button.
  • I manipulate the GameObject’s attributes directly. Keyframes are added. It works great!
  • To simplify the work-flow I have written a GUIEditor that contains sliders controlling just the attributes I want to animate.
  • When I drag the sliders, the attributes of the GameObject change accordingly. All good!
  • The problem: Even though the GameObject’s attributes update, keyframes are not recorded in the Timeline.

Is there a way to force the Timeline to update and add keyframes to any attributes that have changed?

In your GUIEditor, are you using the SerializedProperty versions of the GUI methods?

(The last versions listed in Unity - Scripting API: EditorGUI.Slider). If not, the change will not be picked up by the autokey systems in both the Timeline Window and the Animation Window

1 Like

No, I have not used the serialized versions. Thank you for pointing that out! :slight_smile: