public GameObject Spawn(string name) { SubObjectPool pool = null; if (!m_pools.ContainsKey(name)) { RegisterNewSubObjectPool(name); } pool = m_pools[name]; return(pool.Spawn()); }
public void Unspawn(GameObject go) { SubObjectPool pool = null; foreach (SubObjectPool p in m_pools.Values) { if (p.Contains(go)) { pool = p; break; } } pool.Unspawn(go); }
private void RegisterNewSubObjectPool(string name) { string path = ""; if (string.IsNullOrEmpty(ResourceDir)) { path = name; } else { path = ResourceDir + name; } GameObject prefabs = Resources.Load <GameObject>(path); SubObjectPool pool = new SubObjectPool(prefabs); m_pools.Add(name, pool); }