Search Unity

The way to link custom data to AnimationClip in Animator ?

Discussion in 'Animation' started by RamzaB, Mar 23, 2015.

  1. RamzaB

    RamzaB

    Joined:
    Nov 4, 2012
    Posts:
    42
    Hi,

    I have custom data that links to the animation clips in Animator.
    The way I connect the data in the runtime is like this

    Code (CSharp):
    1.  
    2. animationClipInfo = animator.GetCurrentAnimationClipState(0);
    3. AnimationClip clip = animationClipInfo[0].clip;
    4. MyData data = MyData.Get(clip.name);
    5.  
    As you can see, I am using clip.name as the connector for now, which doesn't sound like a good idea but I don't know if there is any other option.
    And I just found out using the profiler that clip.name actually allocated memory as well.

    So I am wondering if I am doing this wrong, or if there is any other option ?