添加unity容器类,允许使用泛型控制界面上的值。

目前添加了一次最多三个项目的属性。
This commit is contained in:
2025-07-23 20:08:59 +08:00
parent 84d79a430e
commit 49f616f4c7
63 changed files with 2580 additions and 6 deletions
@@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Pool;
using XericLibrary.Runtime.Type;
namespace XericUI.InfiniteVessel
@@ -10,11 +11,69 @@ namespace XericUI.InfiniteVessel
/// </summary>
public abstract class XericInfiniteVesselBase : WeaklyMonoBase
{
#region 字段属性
public GameObject mainItemPrefab;
private ObjectPool<GameObject> _itemPool = null;
#endregion
#region 生命周期
protected virtual void Awake()
{
AwakeInitItemPool();
}
protected virtual void AwakeInitItemPool()
{
_itemPool = new ObjectPool<GameObject>(
CreatItem, GetItemManager, ReleaseItem, DestroyItem);
}
#endregion
#region 对象池操作
/// <summary>
/// 创建对象
/// </summary>
/// <returns></returns>
public virtual GameObject CreatItem()
{
return Object.Instantiate(mainItemPrefab);
}
// public virtual
/// <summary>
/// 获取对象,并获取管理器
/// </summary>
/// <param name="target"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public virtual void GetItemManager(GameObject target)
{
target.SetActive(true);
}
/// <summary>
/// 释放对象
/// </summary>
/// <param name="target"></param>
public virtual void ReleaseItem(GameObject target)
{
target.SetActive(false);
}
/// <summary>
/// 销毁对象
/// </summary>
/// <param name="target"></param>
public virtual void DestroyItem(GameObject target)
{
Object.Destroy(target);
}
#endregion
}
}