44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
|
|
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<AnimationFlow.Runtime.AnimationFlow>();
|
||
|
|
}
|
||
|
|
|
||
|
|
private void Awake()
|
||
|
|
{
|
||
|
|
_holderObjectBase = GetComponent<UIHolderObjectBase>();
|
||
|
|
_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);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|