138 lines
3.1 KiB
C#
138 lines
3.1 KiB
C#
using System;
|
|
using System.Buffers;
|
|
using System.Collections.Generic;
|
|
using AlicizaX.Runtime;
|
|
using UnityEngine;
|
|
|
|
namespace AlicizaX.UI.Runtime
|
|
{
|
|
public abstract partial class UIBase:IEventListenerProxy
|
|
{
|
|
protected System.Object[] userDatas;
|
|
|
|
public System.Object UserData
|
|
{
|
|
get
|
|
{
|
|
if (userDatas != null && userDatas.Length >= 1)
|
|
{
|
|
return userDatas[0];
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public System.Object[] UserDatas => userDatas;
|
|
|
|
/// <summary>
|
|
/// UI实例资源对象。
|
|
/// </summary>
|
|
public GameObject gameObject { protected set; get; }
|
|
|
|
/// <summary>
|
|
/// 窗口位置组件。
|
|
/// </summary>
|
|
public Transform transform => gameObject.transform;
|
|
|
|
/// <summary>
|
|
/// 窗口矩阵位置组件。
|
|
/// </summary>
|
|
public RectTransform rectTransform => gameObject.transform as RectTransform;
|
|
|
|
public virtual string AssetName { get; }
|
|
public virtual bool Visible { set; get; }
|
|
internal bool IsLoaded;
|
|
|
|
protected virtual void OnBindUIComponents()
|
|
{
|
|
}
|
|
|
|
protected virtual void OnInitlize()
|
|
{
|
|
}
|
|
|
|
protected virtual void OnDestroy()
|
|
{
|
|
}
|
|
|
|
protected virtual void OnRegisterEvent()
|
|
{
|
|
}
|
|
|
|
protected virtual void OnOpen()
|
|
{
|
|
}
|
|
|
|
protected virtual void OnClose()
|
|
{
|
|
}
|
|
|
|
|
|
#region UIElement
|
|
|
|
/// <summary>
|
|
/// UI元素节点。
|
|
/// </summary>
|
|
protected UIBindComponent UIBindComponent;
|
|
|
|
/// <summary>
|
|
/// 检测UI元素节点。
|
|
/// </summary>
|
|
protected void InitBindComponent()
|
|
{
|
|
UIBindComponent = rectTransform.GetComponent<UIBindComponent>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取子节点脚本。
|
|
/// </summary>
|
|
/// <typeparam name="T">子节点类型。</typeparam>
|
|
/// <param name="index">子节点索引。</param>
|
|
/// <returns>子节点脚本实例。</returns>
|
|
protected T FChild<T>(int index) where T : Component
|
|
{
|
|
return UIBindComponent.FindChild<T>(index);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region UIEvent
|
|
|
|
public EventListenerProxy EventListener
|
|
{
|
|
get
|
|
{
|
|
if (_uiEventProxy == null)
|
|
{
|
|
_uiEventProxy = ReferencePool.Acquire<EventListenerProxy>();
|
|
}
|
|
|
|
return _uiEventProxy;
|
|
}
|
|
}
|
|
|
|
internal EventListenerProxy _uiEventProxy;
|
|
|
|
protected void RemoveAllUIEvent()
|
|
{
|
|
if (_uiEventProxy != null)
|
|
{
|
|
_uiEventProxy.Clear();
|
|
}
|
|
}
|
|
|
|
protected void DisposeEvent()
|
|
{
|
|
if (_uiEventProxy != null)
|
|
{
|
|
ReferencePool.Release(_uiEventProxy);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|