2025-11-07 20:47:57 +08:00
|
|
|
|
using System;
|
2025-09-05 19:46:30 +08:00
|
|
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace AlicizaX.UI.Runtime
|
|
|
|
|
|
{
|
|
|
|
|
|
[DisallowMultipleComponent]
|
|
|
|
|
|
public abstract class UIHolderObjectBase : UnityEngine.MonoBehaviour
|
|
|
|
|
|
{
|
2025-09-25 11:11:19 +08:00
|
|
|
|
public Action OnWindowInitEvent;
|
2025-12-17 14:32:03 +08:00
|
|
|
|
public Action OnWindowBeforeShowEvent;
|
|
|
|
|
|
public Action OnWindowAfterShowEvent;
|
|
|
|
|
|
public Action OnWindowBeforeClosedEvent;
|
|
|
|
|
|
public Action OnWindowAfterClosedEvent;
|
2025-09-25 11:11:19 +08:00
|
|
|
|
public Action OnWindowDestroyEvent;
|
|
|
|
|
|
|
2025-09-05 19:46:30 +08:00
|
|
|
|
|
|
|
|
|
|
#if ALICIZAX_UI_ANIMATION_SUPPORT
|
|
|
|
|
|
public async UniTask PlayAnimtion(string name)
|
|
|
|
|
|
{
|
2025-09-25 19:28:20 +08:00
|
|
|
|
if (AnimationFlow == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
AnimationFlow = transform.GetComponent<AnimationFlow.Runtime.AnimationFlow>();
|
|
|
|
|
|
}
|
2025-10-14 20:34:00 +08:00
|
|
|
|
|
2025-09-05 19:46:30 +08:00
|
|
|
|
await AnimationFlow.PlayAsync(name);
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private GameObject _target;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// UI实例资源对象。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public GameObject Target => _target ??= gameObject;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private RectTransform _rectTransform;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 窗口矩阵位置组件。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public RectTransform RectTransform => _rectTransform ??= _target.transform as RectTransform;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 可见性
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool Visible
|
|
|
|
|
|
{
|
|
|
|
|
|
get => Target.activeSelf;
|
|
|
|
|
|
|
|
|
|
|
|
internal set { _target.SetActive(value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if ALICIZAX_UI_ANIMATION_SUPPORT
|
|
|
|
|
|
private AnimationFlow.Runtime.AnimationFlow AnimationFlow;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-12-01 16:45:42 +08:00
|
|
|
|
public virtual void Awake()
|
2025-09-05 19:46:30 +08:00
|
|
|
|
{
|
|
|
|
|
|
_target = gameObject;
|
2025-10-14 20:34:00 +08:00
|
|
|
|
#if ALICIZAX_UI_ANIMATION_SUPPORT
|
|
|
|
|
|
AnimationFlow = GetComponent<AnimationFlow.Runtime.AnimationFlow>();
|
|
|
|
|
|
#endif
|
2025-09-05 19:46:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-24 20:44:36 +08:00
|
|
|
|
private bool _isAlive = true;
|
2025-09-05 19:46:30 +08:00
|
|
|
|
|
2026-03-16 20:52:55 +08:00
|
|
|
|
|
2025-12-24 20:44:36 +08:00
|
|
|
|
public bool IsValid()
|
2025-09-05 19:46:30 +08:00
|
|
|
|
{
|
2025-12-24 20:44:36 +08:00
|
|
|
|
return this != null && _isAlive;
|
2025-09-05 19:46:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
|
|
{
|
2025-12-24 20:44:36 +08:00
|
|
|
|
_isAlive = false;
|
2025-09-05 19:46:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|