Skip to content

Instantly share code, notes, and snippets.

@unity3dcollege
Last active May 11, 2017 21:08
Show Gist options
  • Save unity3dcollege/c3b7013a927e7824b3d8bab87ff42106 to your computer and use it in GitHub Desktop.
Save unity3dcollege/c3b7013a927e7824b3d8bab87ff42106 to your computer and use it in GitHub Desktop.
private IPoolable Get()
{
lock (this)
{
if (objects.Count == 0)
{
int amountToGrowPool = Mathf.Max((disabledObjects.Count / 10), 1);
Initialize(this.prefab.GetComponent<IPoolable>(), amountToGrowPool);
}
var pooledObject = objects.Dequeue();
return pooledObject;
}
}
public IPoolable Get(Vector3 position, Quaternion rotation)
{
var pooledObject = Get();
(pooledObject as Component).transform.position = position;
(pooledObject as Component).transform.rotation = rotation;
(pooledObject as Component).gameObject.SetActive(true);
return pooledObject;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment