protected override IEnumerator ProcessPayload(VisualPayload payload) { foreach (var entry in Scope.GetEntries(payload.Data)) { var newSystem = ParticleSystemFactory.GenerateParticleSystem(ParticleSystemPrefabName.GetValue(entry)); var mainColor = MainColor.GetValue(entry); newSystem.startColor = mainColor; if (OverrideColorGradient.GetValue(entry)) { var newGradient = new Gradient(); newGradient.colorKeys = new [] { new GradientColorKey(mainColor, 0f), new GradientColorKey(mainColor, 1f), }; newGradient.alphaKeys = new [] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(1f, .15f), new GradientAlphaKey(0f, 1f) }; var col = newSystem.colorOverLifetime; col.enabled = true; col.color = new ParticleSystem.MinMaxGradient( newGradient); } newSystem.startLifetime = LifeTime.GetValue(entry); // this allegedly works, see http://forum.unity3d.com/threads/enabling-emission.364258/#post-2356966 var emission = newSystem.emission; emission.rate = new ParticleSystem.MinMaxCurve(EmitRate.GetValue(entry)); var newBound = newSystem.GetComponent <BoundingBox>(); if (newBound == null) { newBound = newSystem.gameObject.AddComponent <BoundingBox>(); } payload.VisualData.Bound.ChildWithinBound(newBound.transform); var newVisualizer = newSystem.GetComponent <ParticleSystemVisualizer>(); if (newVisualizer == null) { newVisualizer = newSystem.gameObject.AddComponent <ParticleSystemVisualizer>(); } var newPayload = new VisualPayload(entry.Last(), new VisualDescription(newBound)); newVisualizer.Initialize(this, newPayload); var perParticleSystemIterator = PerParticleSystem.Transmit(newPayload); while (perParticleSystemIterator.MoveNext()) { yield return(null); } } var defaultIterator = DefaultState.Transmit(payload); while (defaultIterator.MoveNext()) { yield return(null); } }