started using generic pooling
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
using Darkmatter.Core;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using UnityEngine;
|
||||
using VContainer;
|
||||
using VContainer.Unity;
|
||||
|
||||
namespace Darkmatter.Presentation
|
||||
{
|
||||
public class ObjectPool<T> : MonoBehaviour,IPool<T> where T : MonoBehaviour, IPoolable
|
||||
public class ObjectPool<T> : MonoBehaviour,IPool<T> where T : Component
|
||||
{
|
||||
[SerializeField] T prefab;
|
||||
[SerializeField] private Transform prefabParent;
|
||||
@@ -29,7 +28,6 @@ namespace Darkmatter.Presentation
|
||||
{
|
||||
T obj = Instantiate(prefab, prefabParent);
|
||||
resolver.InjectGameObject(obj.gameObject);
|
||||
obj.OnSpawn();
|
||||
obj.gameObject.SetActive(false);
|
||||
pool.Enqueue(obj);
|
||||
}
|
||||
@@ -41,7 +39,6 @@ namespace Darkmatter.Presentation
|
||||
{
|
||||
T obj = Instantiate(prefab, prefabParent);
|
||||
resolver.InjectGameObject(obj.gameObject);
|
||||
obj.OnSpawn();
|
||||
obj.gameObject.SetActive(true);
|
||||
pool.Enqueue(obj);
|
||||
return obj;
|
||||
@@ -52,7 +49,6 @@ namespace Darkmatter.Presentation
|
||||
|
||||
public void ReturnToPool(T obj)
|
||||
{
|
||||
obj.OnDespawn();
|
||||
obj.gameObject.SetActive(false);
|
||||
pool.Enqueue(obj);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Presentation
|
||||
{
|
||||
public class PlayerSplashPool : ObjectPool<Splash> { }
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d59f9cfcc85400449668d96f0e2d89c
|
||||
Reference in New Issue
Block a user