AnimatableFloatChannels
A set of named float channels that a script component exposes to the animation system.
Read time 2 minutesLast updated a day ago
Definition
- Type: Class
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
- Implements: IEnumerable<KeyValuePair<string, float>>, IEnumerable
public sealed class AnimatableFloatChannels : IEnumerable<KeyValuePair<string, float>>, IEnumerable
Remarks
Declare a serialized field of this type on a MonoBehaviour to make each of its channels animatable, the same way a SkinnedMeshRenderer makes each blend shape animatable. A channel appears in the Animation window as , where is the name of the field. For example, a channel named in a field named appears as . Channel names can contain periods.
<field>.<channel><field>Smileexpressionsexpressions.SmileThe field must be public or have the SerializeField attribute. Fields with the attribute and fields aren't animatable.
[NonSerialized]readonlyThe component decides which channels exist. Call AnimatableFloatChannels.SetChannels 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 message to the component, in the same way as for an animated field.
OnDidApplyAnimationPropertiesThe following example exposes two channels and logs their values when an animation changes them.
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); }}
Constructors
Constructor | Description |
|---|---|
| AnimatableFloatChannels() | Creates an empty channel set. |
Properties
Property | Description |
|---|---|
| channelCount | The number of channels in the set. |
| this[] | The value of the channel at a position in the set. |
Methods
Method | Description |
|---|---|
| GetChannelName | Gets the name of the channel at a position in the set. |
| GetEnumerator | Gets an enumerator that iterates over the name and value of each channel, in the order of the set. |
| IndexOf | Finds the position of a channel in the set by name. |
| SetChannels | Replaces the channel set with channels that have the given names. |
Structs
Struct | Description |
|---|---|
| AnimatableFloatChannels.Enumerator | Enumerates the name and value of each channel in an AnimatableFloatChannels set. |