Documentation

Unity Engine

Unity Engine

AnimatableObjectChannels

A set of named object reference channels that a script component exposes to the animation system.
Read time 1 minuteLast updated 2 days ago

Definition

public sealed class AnimatableObjectChannels : IEnumerable<KeyValuePair<string, Object>>, IEnumerable

Remarks

Each channel holds a reference to a Unity object, such as a sprite. Animate the channels with object reference curves, in the same way as you animate the sprite of a SpriteRenderer. Declare, name, and bind the channels in the same way as for AnimatableFloatChannels.
The following example exposes two channels and logs the objects they reference when an animation changes them.
using UnityEngine;public class PartSprites : MonoBehaviour{ // Animate these channels as "parts.Head" and "parts.Body". public AnimatableObjectChannels parts = new AnimatableObjectChannels(); // Reset runs when you add the component in the Editor. The channel names are saved with the component. void Reset() { parts.SetChannels("Head", "Body"); } void OnDidApplyAnimationProperties() { foreach (var part in parts) Debug.Log(part.Key + " uses " + (part.Value != null ? part.Value.name : "nothing")); }}

Constructors

Constructor

Description

AnimatableObjectChannels()Creates an empty channel set.

Properties

Property

Description

channelCountThe number of channels in the set.
this[]The object that the channel at a position in the set references.

Methods

Method

Description

GetChannelNameGets the name of the channel at a position in the set.
GetEnumeratorGets an enumerator that iterates over the name and value of each channel, in the order of the set.
IndexOfFinds the position of a channel in the set by name.
SetChannelsReplaces the channel set with channels that have the given names.

Structs

Struct

Description

AnimatableObjectChannels.EnumeratorEnumerates the name and value of each channel in an AnimatableObjectChannels set.