Animator Access Generator For Unity

top feature image

Animator Access Generator For Unity

This video gives a quick overview of Animator Access Generator, an open source C# code generator that makes handling of Animator states and parameters easier.

Note: This became deprecated with Unity3D version 5 with the introduction of State Machine Behaviours.

Aside from this it might be interesting because of some advanced techniques for code generation in editor scripts.

  • 2-step approach when methods are renamed:
    • Previous methods remain in generated code but marked as obsolete. Thus you can refactor your own code to avoid compiler errors
    • On every run the code generator removes all methods marked as obsolete.So clean up is done by running code generation one more time.
  • You don’t have to enter state or parameter names manually any longer as they will be generated automatically.
  • Register event handlers on state changes or transitions that met predefined conditions.
  • Using it will let the compiler detect most possible problems in your code, saving you time consuming bug analysis because of wrong hash IDs.


Most important features:

  • Defines public member variables to hold the hash IDs of all Animator states and parameters and initialises them in Awake () with the correct name string constants
  • Query Animator states by using explicit methods e.g.
    bool IsIdle () for checking a state named Idle
  • Provides dedicated methods for accessing every parameter e.g.
    void SetSpeed (float newValue) and float GetSpeed () for setting a float parameter speed
  • Register event handlers to be called on Animator state changes or transtions e.g.
    anim.TransitionTo (anim.stateIdWalking).OnStarted += OnStartedTransitionToWalking;
    anim.State (anim.stateIdIdle).OnActive += OnIdle;
  • Easy to use through custom editor for AnimatorAccess components
    Animatior Access Custom Editor
  • Supports smooth updates on name changes by analysing the existing class’s code and marks outdated members as obsolete first. They will not be removed before the code is generated one more time
  • Customise the way how variable and method names are built


Animator Access Generator is an open source project hosted at GitHub see:


Code Sample

Excerpt of generated code (see ExamplePlayerAnimatorAccess.cs for full code):

Using generated code (see Player.cs for full code):


Comments are closed.

Durch die weitere Nutzung der Webseite stimmen Sie der Verwendung von Cookies zu Mehr
By continuing to use the site, you agree to the use of cookies. More

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.