Accessing the currently edited animation clip via script?

Hi, I have an Editor Component that needs to access the currently edited animation clip - the one currently present in the “Animation” window with the dope sheet editor. I basically am making a utility that will make some repetitive aspects of our animations easier to manage.

Is there any way to do this?

EDIT:

And/Or is there any way to get the current playhead position of the animation editor?

No one knows the answer? This is really depressing. I’ve been looking through the API for an answer for at least 2 weeks now.

I contacted Mechanim.Dev and he gave me the answer: there is no public interface to the Animation window.

Hope this helps someone in the future.

1 Like

That IS depressing.

What are you trying to do?

I can’t speak for OP, but we’re looking for a similar method for a slightly different use case. Basically we’ve got too many AnimationClips on some Animation components, so I’m trying to make an editor utility where you can choose an AnimationClip in the project, find all the GameObjects in the scene that have Animation components that contain that AnimationClip, and then when you select a given GameObject, it 1) highlights that GO, 2) opens the Animation window, and 3) selects the AnimationClip for editing.

Right now I can do 1) with Selection.activeGameObject, I can do 2) with EditorApplication.ExecuteMenuItem(“Window/Animation”); but I don’t know of any way to do 3).

So is there any way to get/set the currently-edited AnimationClip in the Animation window? (Get for OP, Set for me)

Before 5.5 there is no way to set the currently edited clip

In 5.5 you can now directly select an animation clip in the project view and the animation window will show the animation clip.

1 Like

In 5.4 and previous:
Unless you absolutely must edit the clip on this GameObject, I’d suggest to copy the GameObject, put HideFlags.HideInHierarchy | HideFlags.DontSave on it (so it doesn’t pollute your scene), clear the clip array, and only set the one clip on the Animation component. This way, there’s only this clip to edit.

Bonus points: create a new scene and put it there.

It’s not perfect, but at least it lets you edit your clip.

So, we’re in Unity 5.6 now, and I’m looking to get the Playing animation from the Animation window - through script. I’m not finding much info on this.

Has a way to do this been added anywhere since last September?

Will this be available in Unity 2017?

Hello, I’m not sure if this is what you’re looking for but maybe this post might help anyone trying to add some extra things to the animation window.

I’ve actually managed to make a copy and paste function for an event through the animation window, which isn’t part of the animation window which is a bit wierd lol, and it seems to work quite well :smile:.

Hope that links help you some way!

1 Like

Very sneaky - accessing through reflection. so complicated. Thanks, I’ll try something out with this. :slight_smile:

Haha, I was scared of it before, but decided to just give it a go, should have done this years ago!