You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
using UnityEngine;
|
|
|
|
namespace Game
|
|
{
|
|
public class EntityPoolItem : ObjectPoolItemBase
|
|
{
|
|
public GameObject GameObject;
|
|
|
|
protected override void OnCreate()
|
|
{
|
|
base.OnCreate();
|
|
GameObject.SetActive(false);
|
|
}
|
|
|
|
protected override void OnDestroy()
|
|
{
|
|
base.OnDestroy();
|
|
GameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public class EntityPoolManager : ObjectPoolBase<EntityPoolManager>
|
|
{
|
|
public EntityPoolItem CreateEntity(string entityId)
|
|
{
|
|
var entityNew = Create<EntityPoolItem>($"Entity{entityId}", item =>
|
|
{
|
|
item.GameObject = CreateEntityGo(entityId);
|
|
item.GameObject.transform.SetParent(Root.transform);
|
|
});
|
|
return entityNew;
|
|
}
|
|
|
|
private GameObject CreateEntityGo(string entityId)
|
|
{
|
|
var path = $"{entityId}";
|
|
return PrefabManager.Instance.CreateGo(path);
|
|
}
|
|
}
|
|
} |