# AnimatableFloatChannels

> A set of named float channels that a script component exposes to the animation system.

## Definition

* **Type:** Class
* **Namespace:** [UnityEngine](/engine/7000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule
* **Implements:** [IEnumerable\<KeyValuePair\<string, float>>](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1), [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.ienumerable)

```csharp
public sealed class AnimatableFloatChannels : IEnumerable<KeyValuePair<string, float>>, IEnumerable
```

## Remarks

Declare a serialized field of this type on a [MonoBehaviour](/engine/7000.0/script-reference/unityengine/monobehaviour.md) to make each of its channels animatable, the same way a [SkinnedMeshRenderer](/engine/7000.0/script-reference/unityengine/skinnedmeshrenderer.md) makes each blend shape animatable. A channel appears in the Animation window as `<field>.<channel>`, where `<field>` is the name of the field. For example, a channel named `Smile` in a field named `expressions` appears as `expressions.Smile`. Channel names can contain periods.

The field must be public or have the SerializeField attribute. Fields with the `[NonSerialized]` attribute and `readonly` fields aren't animatable.

The component decides which channels exist. Call [AnimatableFloatChannels.SetChannels](/engine/7000.0/script-reference/unityengine/animatablefloatchannels/setchannels.md) whenever the set changes, for example when a different sprite is assigned. The channel names and values are saved with the component.

When an animation changes the value of a channel, Unity sends the `OnDidApplyAnimationProperties` message to the component, in the same way as for an animated field.

The following example exposes two channels and logs their values when an animation changes them.

```csharp
using UnityEngine;

public class FaceExpressions : MonoBehaviour
{
    // Animate these channels as "expressions.Smile" and "expressions.Blink".
    public AnimatableFloatChannels expressions = new AnimatableFloatChannels();

    // Reset runs when you add the component in the Editor. The channel names are saved with the component.
    void Reset()
    {
        expressions.SetChannels("Smile", "Blink");
    }

    void OnDidApplyAnimationProperties()
    {
        foreach (var channel in expressions)
            Debug.Log(channel.Key + ": " + channel.Value);
    }
}
```

Additional Resources: [AnimatableIntChannels](/engine/7000.0/script-reference/unityengine/animatableintchannels.md), [AnimatableObjectChannels](/engine/7000.0/script-reference/unityengine/animatableobjectchannels.md), [Animator.Rebind](/engine/7000.0/script-reference/unityengine/animator/rebind.md)

## Constructors

| Constructor                                                                                              | Description                   |
| -------------------------------------------------------------------------------------------------------- | ----------------------------- |
| [AnimatableFloatChannels()](/engine/7000.0/script-reference/unityengine/animatablefloatchannels/ctor.md) | Creates an empty channel set. |

## Properties

| Property                                                                                            | Description                                        |
| --------------------------------------------------------------------------------------------------- | -------------------------------------------------- |
| [channelCount](/engine/7000.0/script-reference/unityengine/animatablefloatchannels/channelcount.md) | The number of channels in the set.                 |
| [this\[\]](/engine/7000.0/script-reference/unityengine/animatablefloatchannels/item.md)             | The value of the channel at a position in the set. |

## Methods

| Method                                                                                                  | Description                                                                                        |
| ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| [GetChannelName](/engine/7000.0/script-reference/unityengine/animatablefloatchannels/getchannelname.md) | Gets the name of the channel at a position in the set.                                             |
| [GetEnumerator](/engine/7000.0/script-reference/unityengine/animatablefloatchannels/getenumerator.md)   | Gets an enumerator that iterates over the name and value of each channel, in the order of the set. |
| [IndexOf](/engine/7000.0/script-reference/unityengine/animatablefloatchannels/indexof.md)               | Finds the position of a channel in the set by name.                                                |
| [SetChannels](/engine/7000.0/script-reference/unityengine/animatablefloatchannels/setchannels.md)       | Replaces the channel set with channels that have the given names.                                  |

## Structs

| Struct                                                                                                                  | Description                                                                                                                                                |
| ----------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [AnimatableFloatChannels.Enumerator](/engine/7000.0/script-reference/unityengine/animatablefloatchannels/enumerator.md) | Enumerates the name and value of each channel in an [AnimatableFloatChannels](/engine/7000.0/script-reference/unityengine/animatablefloatchannels.md) set. |
