// Animancer // Copyright 2020 Kybernetik //
using System.Collections.Generic;
using UnityEngine;
namespace Animancer
{
///
/// A based s which can create a
/// when passed into .
///
///
/// When adding a to any derived classes, you can use
/// and .
///
public abstract class AnimancerTransition : ScriptableObject, ITransition, IAnimationClipSource
{
/************************************************************************************************************************/
///
/// Returns the wrapped by this .
///
public abstract ITransition GetTransition();
/************************************************************************************************************************/
/// Wraps .
public float FadeDuration { get { return GetTransition().FadeDuration; } }
/// Wraps .
public object Key { get { return GetTransition().Key; } }
/// Wraps .
public FadeMode FadeMode { get { return GetTransition().FadeMode; } }
/// Wraps .
public AnimancerState CreateState(AnimancerLayer layer)
{
return GetTransition().CreateState(layer);
}
/// Wraps .
public void Apply(AnimancerState state)
{
GetTransition().Apply(state);
}
/************************************************************************************************************************/
/// Wraps .
public void GetAnimationClips(List clips)
{
clips.GatherFromSource(GetTransition());
}
/************************************************************************************************************************/
}
/************************************************************************************************************************/
///
/// An which uses a generic field for its .
///
public class AnimancerTransition : AnimancerTransition where T : ITransition
{
/************************************************************************************************************************/
[SerializeField]
[UnityEngine.Serialization.FormerlySerializedAs("_Animation")]
private T _Transition;
/// []
/// The wrapped by this .
///
/// WARNING: the holds the post recently played state, so
/// if you are sharing this transition between multiple objects it will only remember one of them.
///
/// You can use or
/// to get or create the state for a
/// specific object.
///
public T Transition
{
get { return _Transition; }
set { _Transition = value; }
}
///
/// Returns the wrapped by this .
///
public override ITransition GetTransition() { return _Transition; }
/************************************************************************************************************************/
}
/************************************************************************************************************************/
#if UNITY_EDITOR
namespace Editor
{
[UnityEditor.CustomEditor(typeof(AnimancerTransition), true)]
internal class AnimancerTransitionEditor : ScriptableObjectEditor { }
}
#endif
}