Created
May 11, 2017 21:07
-
-
Save unity3dcollege/506d10212a57f506195ad93f666b7dbe 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 void Initialize(IPoolable poolablePrefab, int initialSize = DEFUALT_POOL_SIZE) | |
{ | |
this.prefab = (poolablePrefab as Component).gameObject; | |
for (int i = 0; i < initialSize; i++) | |
{ | |
var pooledObject = (Instantiate(this.prefab) as GameObject).GetComponent<IPoolable>(); | |
(pooledObject as Component).gameObject.name += " " + i; | |
pooledObject.OnDestroyEvent += () => AddObjectToAvailable(pooledObject); | |
(pooledObject as Component).gameObject.SetActive(false); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment