Adding Animation-Aware Editor Windows

I’m not sure if this is the proper place to ask. I’m looking to make an editor window that allows mass editing of certain components, and these components are expected to be animated. Editing the values of these elements does change the component values, and can be saved (Currently handled by using EditorUtility.SetDirty), but when recording with either the Animation window or Timeline, the values are not reflected in either window: no new curve appears.

I’m assuming AnimationMode.SampleAnimationCurve is the appropriate API to be using here, but my goal is not to write to any old AnimationClip, I aim to edit the AnimationClip currently being edited in the Animation Window, and save the sample to the current time reflected by the Animation Window. I have not come across an API that allows this. Do I need to use reflection to dig into Unity’s internals for this?

Have you tried to manipulate objects via their SerializedObject, rather than manipulating the object directly and then marking it dirty via EditorUtility.SetDirty?

Not sure if that makes a difference, but working with SerializedObject is how a lot of editor code is implemented.

I have two editors for the component in question, one for the normal inspector, one a EditorWindow. The inspector uses SerialzedObject just fine, but also doesn’t react properly to Animation recording.

After refactoring the window to mostly use EditorGUI.PropertyField, it seems to be working. However, the one final control that currently doesn’t work is the one that doesn’t PropertyField, but rather directly altering the value the SerializedProperty holds (boolValue/stringValue/etc). It seems like the logic for injecting changed values into the animation window is done within the actual GUI control.

The control originally was made this way as a workaround to allow us to animate an enum in a discrete, immediate fashion, but this doesn’t seem to be working. Is there a particular reason why enums are not allowed to be animated?