Object Pool Manager for Unity3d Game Engine.
Add RecyclerManager to your scene:
- Create > Empty GameObject > AddComponent > RecyclerManager
using UnityEngine;
using System.Collections;
using GoRecycler;
namespace ExampleNamespace
{
public class ExampleClass : MonoBehaviour
{
public string PoolLabel;
void Start ()
{
// it enables the gameObject by default
GameObject bullet = RecyclerManager.Spawn(PoolLabel, transform.position, transform.rotation);
}
}
}
using UnityEngine;
using System.Collections;
using GoRecycler;
namespace ExampleNamespace
{
public class ExampleClass : MonoBehaviour
{
IEnumerator Start ()
{
yield return new WaitForSeconds(5);
// it disables the gameObject by default
gameObject.Recycle();
}
}
}
using UnityEngine;
using System.Collections;
using GoRecycler;
namespace ExampleNamespace
{
public class ExampleClass : MonoBehaviour
{
void OnEnable ()
{
bool inPool = gameObject.IsOnPool();
if (inPool) Debug.Log("I'm on a Object Pool");
}
}
}
// RecycleBin is the object pool class that handles the Pool to a Prefab
RecycleBin recyclebin = RecyclerManager.GetRecycleBin(gameObject);