Changing Animation speeds in the Inspector

If you want to skip the technical fluff and grab the scripts, click here.

As of Unity 3.0, there is no way to set animation playback speeds directly in the Editor. It can’t even be done through the Animation window! Crazy, right? Not that crazy, it turns out. The catch is, animation playback speeds are stored in AnimationStates that don’t get instantiated until we hit Play. So we have to set the speeds at runtime, usually in Awake or Update. Most of the time we end up putting that functionality in one or two scripts that do very specific things like controlling a character and that’s not scalable to all the other objects in our scene that have animations. What do we do?

Here’s one solution to this problem. We all know by now* that Editor scripts (of the Editor-class type) can be used to customize our Inspector views. First step is to create an Editor that targets the Animation component and simply add some sliders at the bottom of it for each animation held in the Animations list. Second step is to create an accompanying and generalized MonoBehaviour script that will assign the proper values from the sliders to the AnimationStates upon Awake and/or Update.

And here it is:

Animation Editor

The two scripts at work here are:

– AnimationSpeedEditor.cs which appends our GUI controls to the end of the Animation component view in the Inspector. These GUI controls allow you to set different playback speeds for each animation clip in the Animations list.

– OverrideAnimationSpeeds.cs which overwrites the default animation speed of 1 with the values gathered from the sliders in the Inspector.

A couple important points:

The additional GUI controls get activated if and only if you have the OverrideAnimationSpeeds component attached to the game object that has the Animation component.
Also, you’re not going to see anything under the Animation speeds foldout if you don’t have any animation clips in the Animations list.



  • Download, which contains two script files: AnimationSpeedEditor.cs and OverrideAnimationSpeeds.cs.
  • Place AnimationSpeedEditor.cs inside a folder named Editor in your project. Create the folder if it doesn’t exist. The other script file can be placed pretty much anywhere.
  • Find or create a game object that has an Animation component attached, and add the OverrideAnimationSpeeds component to it. You should see the Animation Speeds foldout get added to the view of the Animation component (as seen in the picture above.)
  • Open the foldout. If you have animation clips added to the Animations list of your Animation component, you’ll see sliders for each one. Use these sliders to set a starting speed for your animations. You can also use the sliders during Play mode and see the results immediately.

As always, contact me with any feedback or bug reports. You can PM me on the Unity Forums, catch me on Twitter, or shoot me an e-mail. E-mail address is in the About box down and to the left. Thanks, folks!


About this entry