Skip to content

Object Pool Manager for unity3d game engine

License

Notifications You must be signed in to change notification settings

pedro15/GoRecycler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoRecycler

Object Pool Manager for Unity3d Game Engine.

ScreenShot

Getting started

Add RecyclerManager to your scene:

  • Create > Empty GameObject > AddComponent > RecyclerManager

Get from Object Pool

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);
        }
    }
}

Recycle to Object Pool

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();
        }
    }
}

Check if the GameObject is on a Object Pool

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");
        }
    }
}

Get the object pool asigned to the Game Object

// RecycleBin is the object pool class that handles the Pool to a Prefab
RecycleBin recyclebin = RecyclerManager.GetRecycleBin(gameObject);

About

Object Pool Manager for unity3d game engine

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages