public void AddAnimation(AnimationType animationType,
GameObject referenceGameObject,
bool resetToOriginal = true,
ScriptableObject animationSettings = null,
Action onComplete = null)
{
if (animationType == AnimationType.None)
{
onComplete?.Invoke();
return;
}
if (!AnimationList.ContainsKey(referenceGameObject))
{
AnimationList.Add(referenceGameObject, new List <AnimationHandler>());
}
var existsAnimationHandler = AnimationList[referenceGameObject].Find(x => x.AnimationType == animationType);
if (existsAnimationHandler != null)
{
StopAnimation(existsAnimationHandler.ReferenceObject, existsAnimationHandler.AnimationType);
return;
}
AnimationHandler animationHandler = new AnimationHandler();
animationHandler.AnimationType = animationType;
animationHandler.ReferenceObject = referenceGameObject;
animationHandler.ResetToOriginal = resetToOriginal;
animationHandler.OnComplete = onComplete;
AnimationList[referenceGameObject].Add(animationHandler);
if (animationSettings != null)
{
animationHandler.AnimationSettings = animationSettings;
}
animationHandler.Start();
}