Hi, I know how to set up the rateOverTime of ParticleSystem and its other properties, but I don’t know how to store the initial value of rateOverTime to other variables before I turn them to zero, so I can toggle them.
Set ParticleSystem > emission > rateOverTime to zero:
/* ProjectileController.cs */
void OnCollisionEnter2D (Collision2D other) //void OnCollisionStay2D (Collision2D other)
{
if (!enable) return;
if (other.gameObject.CompareTag ("Enemy"))
{
foreach (ParticleSystem thisBulletTail in bulletTail)
{
var em = thisBulletTail.GetComponent<ParticleSystem> ().emission;
em.rateOverTime = 0f;
}
}
}
But first, I want their initial value to be stored in array (with float?) in Start ()…
How can I do that if their type is like this:
var PS_1 = bulletTail[0].GetComponent<ParticleSystem> ();
Debug.Log ("ParticleSystem: " + PS_1.GetType());
var PS_2 = bulletTail[0].GetComponent<ParticleSystem> ().emission;
Debug.Log ("PS.emission: " + PS_2.GetType());
var PS_3 = bulletTail[0].GetComponent<ParticleSystem> ().emission.rateOverTime;
Debug.Log ("PS.emission.rateOverTime: " + PS_3.GetType());
var PS_4 = bulletTail[0].GetComponent<ParticleSystem> ().emission.rateOverDistance;
Debug.Log ("PS.emission.rateOverDistance: " + PS_4.GetType());
So this won’t do:
float[] rateOverDistance;
And there’s no:
var[] rateOverDistance;
Is there easy way to do this? I can’t just deactivate the whole object, because the particle effects will also be hidden. I just plan to deactivate some components: SpriteRenderer, ProjectileController, and ParticleSystem’s emission’s rateOverDistance, and toggle them as I pooling them to recycle. Not destroying or deactivate the gameObject.
Thank you!
