// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2024 Kybernetik // using System; using System.Collections.Generic; using UnityEngine; namespace Animancer { /// A which gets its clip from a . /// /// /// /// Documentation: /// /// Directional Animation Sets /// /// Example: /// // Leave the Clip field empty in the Inspector and assign its AnimationSet instead. /// [SerializeField] private DirectionalClipTransition _Transition; /// /// ... /// /// // Then you can just call SetDirection and Play it like any other transition. /// // All of the transition's details like Fade Duration and Events will be applied to whichever clip is plays. /// _Transition.SetDirection(Vector2.right); /// _Animancer.Play(_Transition); /// /// /// https://kybernetik.com.au/animancer/api/Animancer/DirectionalClipTransition /// [Serializable] public class DirectionalClipTransition : ClipTransition, ICopyable { /************************************************************************************************************************/ [SerializeField] [Tooltip("The animations which used to determine the " + nameof(Clip))] private DirectionalAnimationSet _AnimationSet; /// [] /// The used to determine the . /// public ref DirectionalAnimationSet AnimationSet => ref _AnimationSet; /// public override UnityEngine.Object MainObject => _AnimationSet; /// The name of the serialized backing field of . public const string AnimationSetField = nameof(_AnimationSet); /************************************************************************************************************************/ /// Sets the from the . public void SetDirection(Vector2 direction) => Clip = _AnimationSet.GetClip(direction); /// Sets the from the . public void SetDirection(int direction) => Clip = _AnimationSet.GetClip(direction); /// Sets the from the . public void SetDirection(DirectionalAnimationSet.Direction direction) => Clip = _AnimationSet.GetClip(direction); /// Sets the from the . public void SetDirection(DirectionalAnimationSet8.Direction direction) => Clip = _AnimationSet.GetClip((int)direction); /************************************************************************************************************************/ /// public override void GatherAnimationClips(ICollection clips) { base.GatherAnimationClips(clips); clips.GatherFromSource(_AnimationSet); } /************************************************************************************************************************/ /// public virtual void CopyFrom(DirectionalClipTransition copyFrom, CloneContext context) { base.CopyFrom(copyFrom, context); if (copyFrom == null) { _AnimationSet = default; return; } _AnimationSet = copyFrom._AnimationSet; } /************************************************************************************************************************/ } }