using System.Collections.Generic; using System.Linq; using UnityEngine; namespace Wizard; [ExecuteAlways] public class TweenAnimation : MonoBehaviour { [SerializeField] private float _duration; private List _tweenList = new List(); private bool _isPlaying; public void Play() { _isPlaying = true; CollectTween(); SetupTweenParam(); foreach (UITweener tween in _tweenList) { tween.ResetToBeginning(); tween.PlayForward(); tween.SetOnFinished(delegate { _isPlaying = false; }); } } private void CollectTween() { _tweenList = base.gameObject.GetComponents().ToList(); } private void SetupTweenParam() { foreach (UITweener tween in _tweenList) { tween.duration = _duration - tween.delay; } } public bool IsPlayEnd() { return !_isPlaying; } }