com.alicizax.unity.ui.exten.../Runtime/RecyclerView/ObjectPool/UnityComponentFactory.cs
陈思海 dc8c840d69 RecyclerView 大优化
优化RecycleView 渲染架构
优化RecyclerView 渲染性能 增加 缓存 异步
增加Navagation导航锚点相关
2026-03-31 15:18:50 +08:00

39 lines
777 B
C#

namespace AlicizaX.UI
{
using UnityEngine;
public class UnityComponentFactory<T> : IObjectFactory<T> where T : Component
{
private T template;
private Transform parent;
public UnityComponentFactory(T template, Transform parent)
{
this.template = template;
this.parent = parent;
}
public T Create()
{
T obj = Object.Instantiate(template, parent);
return obj;
}
public void Destroy(T obj)
{
Object.Destroy(obj.gameObject);
}
public void Reset(T obj)
{
obj.gameObject.SetActive(false);
}
public bool Validate(T obj)
{
return true;
}
}
}