78 lines
2.5 KiB
C#
78 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using AlicizaX.UI.Runtime;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
namespace AlicizaX.UI.Extension.UXComponent
|
|
{
|
|
[RequireComponent(typeof(AnimationFlow.Runtime.AnimationFlow))]
|
|
public class UXUIAnimation : MonoBehaviour
|
|
{
|
|
[ReadOnly] [SerializeField] private AnimationFlow.Runtime.AnimationFlow animationFlow;
|
|
|
|
[LabelText("显示动画")] [BoxGroup("基础设置", true)] [ValueDropdown("GetAllAnimationClips", ExpandAllMenuItems = true)] [SerializeField]
|
|
private string ShowAnimationName;
|
|
|
|
[LabelText("关闭动画")] [BoxGroup("基础设置", true)] [ValueDropdown("GetAllAnimationClips", ExpandAllMenuItems = true)] [SerializeField]
|
|
private string HideAnimationName;
|
|
|
|
[LabelText("关闭动画")] [BoxGroup("基础设置", true)] [ValueDropdown("GetAllAnimationClips", ExpandAllMenuItems = true)] [SerializeField]
|
|
private string InitAnimationName;
|
|
|
|
private UIHolderObjectBase _holderObjectBase;
|
|
#if UNITY_EDITOR
|
|
public List<string> GetAllAnimationClips
|
|
{
|
|
get
|
|
{
|
|
if (animationFlow == null)
|
|
{
|
|
animationFlow = GetComponent<AnimationFlow.Runtime.AnimationFlow>();
|
|
}
|
|
|
|
return animationFlow.GetAllAnimationClips;
|
|
}
|
|
}
|
|
|
|
#endif
|
|
private void OnValidate()
|
|
{
|
|
animationFlow = GetComponent<AnimationFlow.Runtime.AnimationFlow>();
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
_holderObjectBase = GetComponent<UIHolderObjectBase>();
|
|
_holderObjectBase.OnWindowShowEvent += ShowAnimation;
|
|
_holderObjectBase.OnWindowClosedEvent += CloseAnimation;
|
|
_holderObjectBase.OnWindowInitEvent += InitAnimation;
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
_holderObjectBase.OnWindowInitEvent -= InitAnimation;
|
|
_holderObjectBase.OnWindowShowEvent -= ShowAnimation;
|
|
_holderObjectBase.OnWindowClosedEvent -= CloseAnimation;
|
|
}
|
|
|
|
private void InitAnimation()
|
|
{
|
|
if (!string.IsNullOrEmpty(InitAnimationName))
|
|
{
|
|
animationFlow.Play(InitAnimationName);
|
|
}
|
|
}
|
|
|
|
internal void ShowAnimation()
|
|
{
|
|
animationFlow.Play(ShowAnimationName);
|
|
}
|
|
|
|
internal void CloseAnimation()
|
|
{
|
|
animationFlow.Play(HideAnimationName);
|
|
}
|
|
}
|
|
}
|