MultiEmitOnEvent.cs 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. using UnityEngine;
  2. using System.Collections;
  3. using ParticlePlayground;
  4. /// <summary>
  5. /// Emit several particles upon a particle event.
  6. /// </summary>
  7. public class MultiEmitOnEvent : MonoBehaviour {
  8. public PlaygroundParticlesC particlesEvent; // The event particle system
  9. public PlaygroundParticlesC particlesEmit; // The emission particle system
  10. public int emitCount = 8; // The amount of particles
  11. public Vector3 randomVelocityMin = new Vector3(-1f,0,-1f); // The minimum random velocity
  12. public Vector3 randomVelocityMax = new Vector3(1f,1f,1f); // The maximum random velocity
  13. public Color32 color = Color.white; // The color of particles
  14. void Start () {
  15. // Specify which event you would like to listen to
  16. PlaygroundC.GetEvent (0, particlesEvent).particleEvent += EmitOnEvent;
  17. }
  18. /// <summary>
  19. /// Emits particles whenever the event is triggered. You could use more info from the passed in event particle if you'd like for more advanced emission behaviors.
  20. /// Note that this will by default be called on a second thread.
  21. /// </summary>
  22. /// <param name="particle">Event Particle.</param>
  23. void EmitOnEvent (PlaygroundEventParticle particle) {
  24. particlesEmit.ThreadSafeEmit (emitCount, particle.collisionParticlePosition, randomVelocityMin, randomVelocityMax, color);
  25. }
  26. }