Getting Animations
From an Animatable
You can get an animation from any Animatable component.
Animatable UI Objects
You can get the on enable, on disable, or custom call animations of any AnimatableRectTransform, AnimatableImage, AnimatableCanvasGroup, AnimatableText, and AnimatableButton by index.
// Getting the first animation of each animation type
// 'animatable' is any AnimatableUIObject
UIAnimationData enableAnim = animatable.onEnableAnimations[0];
UIAnimationData disableAnim = animatable.onDisableAnimations[0];
UIAnimationData customCallAnim = animatable.customCallAnimations[0];
Animatable Transform
Animatable transforms only consist of a single list of animations. Similar to the animatable UI objects, you can get the animation by index.
// Getting the first animation
// 'animatable' is an AnimatableTransform
TransformAnimationData anim = animatable.animations[0];
From the Animation Creator
When an animation is created by any Animation Creator extension (such as transform.Move
, rectTransform.Rotate
, etc.), the created animation is returned. So, you can get the animation by simply creating a variable for it.
// 'number' is a float
AnimationData anim = AnimationCreator.FloatAnimation(0, 100, (x) => number = x, 1);
Last updated