Get property name for animations

Hello everybody ! :slight_smile:

I am currently scripting an animation in C#. I know how to create an animation from scratch :

  1. Create an Animation Clip
  2. Create an Animation Curve
  3. Add keyframes to the animation curve
  4. Set the curve to the clip
  5. Add the clip to the Animation component of my gameobject

But, I have a problem when I look for the property which will be modified by the edited curve : AnimationClip.SetCurve(string relativePath, Type type, string propertyName, AnimationCurve curve); (See Unity documentation of the function).

It is quite simple to retrieve localPosition, etc, but I don’t know how to retrieve the fill Amount of an image for instance. I have tried the following line and many other possibilities… I have tried with a simpler property : color.a but same result…

clip.SetCurve( "", typeof(Image), "fillAmount", fillAmountCurve );

My gameobject has an Image component and an Animation component.

Do you know if there is a “rule” to get any property ?

Tried to do the same stuff:

clip.SetCurve( "", typeof(Image), "fillAmount", fillAmountCurve );

Faced the same problem. Didn’t find the way to animate like that, despite the fact that Unity guys say in Unity 5 docs this:

Property names can be looked up by setting Asset Serialization to Force Text mode in the Editor settings. The text files that are then written by the editor will include the names of the properties.

From my .unity file found that the proper name for fillAmount is m_FillAmount, but it doesn’t work either. My guess is that it should be either not an Image for typeof or not fillAmount of any sort.

So far ended with a workaround found here:

using UnityEngine;

public class FillAnimator : MonoBehaviour
{
    public float fillValue; // <-- animate this

    void Update() { GetComponent<UISprite>().fillAmount = fillValue;
}