public static void Apply(GameObject rootObj) { PooledParticles pp = rootObj.AddComponent <PooledParticles>(); foreach (var a in pp.animators) { var e = a.particleEmitter; if (!e) { continue; } if (e.emit) { pp.emitOnStart.Add(e); } if (a.autodestruct) { if (a.transform == rootObj.transform) { pp.despawnOnAutoStop = true; } a.autodestruct = false; pp.autoStopEmitters.Add(e); } } }
private GameObject CreateNew(Vector3 position, Quaternion rotation) { GameObject obj = (GameObject)GameObject.Instantiate(prefab, position, rotation); if (obj.GetComponentInChildren <ParticleEmitter>() != null) { PooledParticles.Apply(obj); } return(obj); }
void Awake() { main = this; }