/// <summary> /// Sets emission on/off. /// </summary> /// <param name="playgroundParticles">Playground particles.</param> /// <param name="setEmission">If set to <c>true</c> set emission.</param> public static void Emit (PlaygroundParticlesC playgroundParticles, bool setEmission) { playgroundParticles.Emit(setEmission); }
/// <summary> /// Emits next particle - using the particle system as a pool (note that you need to set scriptedEmission-variables on beforehand using this method). Returns emitted particle number. /// </summary> /// <param name="playgroundParticles">Playground particles.</param> public static int Emit (PlaygroundParticlesC playgroundParticles) { return playgroundParticles.Emit(playgroundParticles.scriptedEmissionPosition,playgroundParticles.scriptedEmissionVelocity,playgroundParticles.scriptedEmissionColor); }
/// <summary> /// Emits next particle while setting scriptedEmission data - using the particle system as a pool. Returns emitted particle number. /// </summary> /// <param name="playgroundParticles">Playground particles.</param> /// <param name="position">Position.</param> /// <param name="normal">Normal.</param> /// <param name="color">Color.</param> public static int Emit (PlaygroundParticlesC playgroundParticles, Vector3 position, Vector3 normal, Color color) { return playgroundParticles.Emit(position,normal,color); }
// Updates a PlaygroundParticlesC object (called from Playground) public static void Update (PlaygroundParticlesC playgroundParticles) { if (playgroundParticles.isYieldRefreshing || playgroundParticles.isLoading || playgroundParticles.playgroundCache==null) return; // Emission halt for disabling called from calculation thread if (playgroundParticles.queueEmissionHalt) playgroundParticles.particleSystemGameObject.SetActive(false); // Particle count if (playgroundParticles.particleCount!=playgroundParticles.previousParticleCount) { SetParticleCount(playgroundParticles, playgroundParticles.particleCount); playgroundParticles.Start(); return; } // Particle emission if (playgroundParticles.emit!=playgroundParticles.previousEmission) { playgroundParticles.Emit (playgroundParticles.emit); } // 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.sorting, playgroundParticles.lifetime); return; } // Particle emission rate if (playgroundParticles.previousEmissionRate!=playgroundParticles.emissionRate) SetEmissionRate(playgroundParticles); // Particle state change 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.previousActiveState = playgroundParticles.activeState; } // Particle calculation if (PlaygroundC.reference.calculate && playgroundParticles.calculate && !playgroundParticles.inTransition) ThreadedCalculations(playgroundParticles); else playgroundParticles.cameFromNonCalculatedFrame = true; // Assign all particles into the particle system if (!playgroundParticles.inTransition && playgroundParticles.particleCache.Length>0 && playgroundParticles.calculate) playgroundParticles.shurikenParticleSystem.SetParticles(playgroundParticles.particleCache, playgroundParticles.particleCache.Length); // Make sure this particle system is playing if (playgroundParticles.shurikenParticleSystem.isPaused || playgroundParticles.shurikenParticleSystem.isStopped) playgroundParticles.shurikenParticleSystem.Play(); }