Last active
May 11, 2017 21:08
-
-
Save unity3dcollege/c3b7013a927e7824b3d8bab87ff42106 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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