// Updates a PlaygroundParticlesC object (called from Playground) public static void Update (PlaygroundParticlesC playgroundParticles) { // Particle count if (playgroundParticles.particleCount!=playgroundParticles.previousParticleCount) { SetParticleCount(playgroundParticles, playgroundParticles.particleCount); playgroundParticles.Start(); } // Particle emission if (playgroundParticles.emit!=playgroundParticles.previousEmission) Emission(playgroundParticles, playgroundParticles.emit, true); // Particle size if (playgroundParticles.sizeMin!=playgroundParticles.previousSizeMin || playgroundParticles.sizeMax!=playgroundParticles.previousSizeMax) SetSizeRandom(playgroundParticles, playgroundParticles.sizeMin, playgroundParticles.sizeMax); // Particle rotation if (playgroundParticles.initialRotationMin!=playgroundParticles.previousInitialRotationMin || playgroundParticles.initialRotationMax!=playgroundParticles.previousInitialRotationMax) SetInitialRotationRandom(playgroundParticles, playgroundParticles.initialRotationMin, playgroundParticles.initialRotationMax); if (playgroundParticles.rotationSpeedMin!=playgroundParticles.previousRotationSpeedMin || playgroundParticles.rotationSpeedMax!=playgroundParticles.previousRotationSpeedMax) SetRotationRandom(playgroundParticles, playgroundParticles.rotationSpeedMin, playgroundParticles.rotationSpeedMax); // Particle velocity if (playgroundParticles.applyInitialVelocity) if (playgroundParticles.initialVelocityMin!=playgroundParticles.previousVelocityMin || playgroundParticles.initialVelocityMax!=playgroundParticles.previousVelocityMax || playgroundParticles.playgroundCache.initialVelocity==null || playgroundParticles.playgroundCache.initialVelocity.Length!=playgroundParticles.particleCount) SetVelocityRandom(playgroundParticles, playgroundParticles.initialVelocityMin, playgroundParticles.initialVelocityMax); // Particle local velocity if (playgroundParticles.applyInitialLocalVelocity) if (playgroundParticles.initialLocalVelocityMin!=playgroundParticles.previousLocalVelocityMin || playgroundParticles.initialLocalVelocityMax!=playgroundParticles.previousLocalVelocityMax || playgroundParticles.playgroundCache.initialLocalVelocity==null || playgroundParticles.playgroundCache.initialLocalVelocity.Length!=playgroundParticles.particleCount) SetLocalVelocityRandom(playgroundParticles, playgroundParticles.initialLocalVelocityMin, playgroundParticles.initialLocalVelocityMax); // Particle life if (playgroundParticles.previousLifetime!=playgroundParticles.lifetime) SetLifetime(playgroundParticles, playgroundParticles.lifetime); // Particle emission rate if (playgroundParticles.previousEmissionRate!=playgroundParticles.emissionRate) SetEmissionRate(playgroundParticles); // Particle state change transition if (playgroundParticles.source==SOURCEC.State && playgroundParticles.activeState!=playgroundParticles.previousActiveState) { if (playgroundParticles.states[playgroundParticles.activeState].positionLength>playgroundParticles.particleCount) SetParticleCount(playgroundParticles, playgroundParticles.states[playgroundParticles.activeState].positionLength); playgroundParticles.InitTransition(playgroundParticles); playgroundParticles.previousActiveState = playgroundParticles.activeState; } // Particle calculation if (PlaygroundC.reference.calculate && playgroundParticles.calculate && !playgroundParticles.inTransition) Calculate(ref playgroundParticles); else playgroundParticles.cameFromNonCalculatedFrame = true; // Assign all particles into the particle system if (!playgroundParticles.inTransition && playgroundParticles.particleCache.particles.Length>0) playgroundParticles.shurikenParticleSystem.SetParticles(playgroundParticles.particleCache.particles, playgroundParticles.particleCache.particles.Length); // Make sure that variables are reset till next frame playgroundParticles.isPainting = false; }