using UnityEngine; using System.Collections; using ParticlePlayground; // Example of scripted preset emitting in a circle on instantiation. // To instantiate this during runtime as a preset use: Playground.InstantiatePreset("Playground Circle Shot (Script)"); [ExecuteInEditMode()] [RequireComponent(typeof(PlaygroundParticlesC))] public class PlaygroundPresetCircleShotC : MonoBehaviour { public int numberOfParticles = 30; // The number of particles to emit each cycle public float force = 10f; // The force to emit in forward direction public int cycles = 1; // The number of cycles to emit public Vector3 rotationNormal = new Vector3(0,0,1); // The axis you want to rotate around public float minimumLifetime = 3f; // The minimum lifetime of a particle public float maximumLifetime = 3f; // The maximum lifetime of a particle public Color color = Color.white; // The color of particle public float yieldBeforeEmission = 0f; // The seconds to wait before starting emission public float yieldBetweenShots = 0f; // The seconds between shots (if any) public float yieldBetweenCycles = 0f; // The seconds between cycles (if any) public WhenDoneCircleShot whenDone; // Should this GameObject inactivate or destroy when emission is done? private Transform thisTransform; private PlaygroundParticlesC particles; bool isSameLifetime = false; void Start () { particles = GetComponent(); thisTransform = transform; isSameLifetime = minimumLifetime==maximumLifetime; StartCoroutine(Shoot()); } IEnumerator Shoot () { // We need to wait before the particle system is fully ready before we start to call for our emission while (!particles.Initialized ()) yield return null; // Set variables float rotationSpeed = 360f/numberOfParticles; float timeDone; // Set particle count to match the amount needed particles.particleCount = numberOfParticles*cycles; // Wait before emission starts (if applicable) if (yieldBeforeEmission>0) { timeDone = PlaygroundC.globalTime+yieldBeforeEmission; while (PlaygroundC.globalTime0) { timeDone = PlaygroundC.globalTime+yieldBetweenShots; while (PlaygroundC.globalTime0) { timeDone = PlaygroundC.globalTime+yieldBetweenCycles; while (PlaygroundC.globalTime