Skip to content

Instantly share code, notes, and snippets.

@unity3dcollege
Created May 11, 2017 21:50
Show Gist options
  • Save unity3dcollege/e20fc2ef5c859b56bc052f13299aa6d7 to your computer and use it in GitHub Desktop.
Save unity3dcollege/e20fc2ef5c859b56bc052f13299aa6d7 to your computer and use it in GitHub Desktop.
public static Pool GetPool(IPoolable prefab)
{
if (pools.ContainsKey(prefab))
{
if (pools[prefab] != null)
return pools[prefab];
else
pools.Remove(prefab);
}
var pool = new GameObject("Pool-" + (prefab as Component).name).AddComponent<Pool>();
pool.Initialize(prefab);
pools.Add(prefab, pool);
return pool;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment