add project files
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace OHM.UnityToolkit.Pooling
|
||||
{
|
||||
public class PooledObject : MonoBehaviour
|
||||
{
|
||||
private int poolId;
|
||||
|
||||
private bool _used;
|
||||
|
||||
public int PoolId => poolId;
|
||||
|
||||
public bool Used => _used;
|
||||
|
||||
public void Use()
|
||||
{
|
||||
_used = true;
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
_used = false;
|
||||
}
|
||||
|
||||
public void AddToPool(int poolId)
|
||||
{
|
||||
this.poolId = poolId;
|
||||
}
|
||||
|
||||
public void RemoveFromPool()
|
||||
{
|
||||
poolId = -1;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (poolId != -1)
|
||||
{
|
||||
Debug.LogWarning("Pooled object " + base.name
|
||||
+ "destroyed whereas not ready. You should not destroy a pooled , but use the PoolsManager");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user