using System; using AlicizaX.UI.Runtime; using UnityEngine; namespace AlicizaX.UI.Extension.UXComponent { [RequireComponent(typeof(AnimationFlow.Runtime.AnimationFlow))] public class UXUIAnimation : MonoBehaviour { [SerializeField] private AnimationFlow.Runtime.AnimationFlow animationFlow; [SerializeField] private string ShowAnimationName = "Show"; [SerializeField] private string HideAnimationName = "Close"; private UIHolderObjectBase _holderObjectBase; private void OnValidate() { animationFlow = GetComponent(); } private void Awake() { _holderObjectBase = GetComponent(); _holderObjectBase.OnWindowShowEvent += ShowAnimation; _holderObjectBase.OnWindowClosedEvent += CloseAnimation; } private void OnDestroy() { _holderObjectBase.OnWindowShowEvent -= ShowAnimation; _holderObjectBase.OnWindowClosedEvent -= CloseAnimation; } internal void ShowAnimation() { animationFlow.Play(ShowAnimationName); } internal void CloseAnimation() { animationFlow.Play(HideAnimationName); } } }