Object pooling is a process of reusing the same GameObject instance instead of repetitively creating and destroying it.
In this script you will find two different sets of methods for pooling objects one for GameObject and another for AudioClip components. Use them as per your use case.
Use object ObjectPooling.GetObject(prefab) instead of Instantiate(prefab) whenever you want to create or destroy a GameObject multiple times, When you no longer need the object use ObjectPooling.ReturnObject(prefab,instance) .
By default every visual/audio effect used by this framework has object pooling.
If you wish you can add this script to a GameObject in your scene to have all the object pools in there Otherwise a GameObject will be created automatically.
static public GameObject GetObject(GameObject prefab, Vector3 position ,Quaternion rotation,Transform parent = null)
Use this method in most cases when you want to pool a GameObject.
It returns the instantiated GameObject
static public GameObject GetObject(GameObject prefab)
Overload for GetObject, here the position and rotation will be zeroed and the parent will be **objectPoolParent.**