Version: 2017.3 (switch to 2017.4)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Method group is Obsolete

ParticleSystem.EmissionModule.rate

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
Obsolete public var rate: ParticleSystem.MinMaxCurve;
Obsolete public ParticleSystem.MinMaxCurve rate;

Description

The rate at which new particles are spawned.

See Also: MinMaxCurve.

#pragma strict
// This example shows setting a constant rate value.
public class ConstantRateExample extends MonoBehaviour {
	var myParticleSystem: ParticleSystem;
	var emissionModule: ParticleSystem.EmissionModule;
	function Start() {
		// Get the system and the emission module.
		myParticleSystem = GetComponent.<ParticleSystem>();
		emissionModule = myParticleSystem.emission;
		GetValue();
		SetValue();
	}
	function GetValue() {
		print("The constant value is " + emissionModule.rate.constant);
	}
	function SetValue() {
		emissionModule.rate = 10.0f;
	}
}
using UnityEngine;

// This example shows setting a constant rate value. public class ConstantRateExample : MonoBehaviour { ParticleSystem myParticleSystem; ParticleSystem.EmissionModule emissionModule;

void Start() { // Get the system and the emission module. myParticleSystem = GetComponent<ParticleSystem>(); emissionModule = myParticleSystem.emission;

GetValue(); SetValue(); }

void GetValue() { print("The constant value is " + emissionModule.rate.constant); }

void SetValue() { emissionModule.rate = 10.0f; } }
#pragma strict
// This example shows using 2 constants to drive the rate.
public class TwoConstantsRateExample extends MonoBehaviour {
	var myParticleSystem: ParticleSystem;
	var emissionModule: ParticleSystem.EmissionModule;
	function Start() {
		// Get the system and the emission module.
		myParticleSystem = GetComponent.<ParticleSystem>();
		emissionModule = myParticleSystem.emission;
		GetValue();
		SetValue();
	}
	function GetValue() {
		print(String.Format("The constant values are: min {0} max {1}.", emissionModule.rate.constantMin, emissionModule.rate.constantMax));
	}
	function SetValue() {
		emissionModule.rate = new ParticleSystem.MinMaxCurve(0.0f, 10.0f);
	}
}
using UnityEngine;

// This example shows using 2 constants to drive the rate. public class TwoConstantsRateExample : MonoBehaviour { ParticleSystem myParticleSystem; ParticleSystem.EmissionModule emissionModule;

void Start() { // Get the system and the emission module. myParticleSystem = GetComponent<ParticleSystem>(); emissionModule = myParticleSystem.emission;

GetValue(); SetValue(); }

void GetValue() { print(string.Format("The constant values are: min {0} max {1}.", emissionModule.rate.constantMin, emissionModule.rate.constantMax)); }

void SetValue() { emissionModule.rate = new ParticleSystem.MinMaxCurve(0.0f, 10.0f); } }
#pragma strict
// This example shows using a curve to drive the rate.
public class CurveRateExample extends MonoBehaviour {
	var myParticleSystem: ParticleSystem;
	var emissionModule: ParticleSystem.EmissionModule;
	public var scalar: float = 1.0f;
	var ourCurve: AnimationCurve;
	function Start() {
		// Get the system and the emission module.
		myParticleSystem = GetComponent.<ParticleSystem>();
		emissionModule = myParticleSystem.emission;
		// A simple linear curve.
		ourCurve = new AnimationCurve();
		ourCurve.AddKey(0.0f, 0.0f);
		ourCurve.AddKey(1.0f, 1.0f);
		// Apply the curve.
		emissionModule.rate = new ParticleSystem.MinMaxCurve(scalar, ourCurve);
		// In 5 seconds we will modify the curve.
		Invoke("ModifyCurve", 5.0f);
	}
	function ModifyCurve() {
		// Add a key to the current curve.
		ourCurve.AddKey(0.5f, 0.0f);
		// Apply the changed curve.
		emissionModule.rate = new ParticleSystem.MinMaxCurve(scalar, ourCurve);
	}
}
using UnityEngine;

// This example shows using a curve to drive the rate. public class CurveRateExample : MonoBehaviour { ParticleSystem myParticleSystem; ParticleSystem.EmissionModule emissionModule;

// We can "scale" the curve with this value. It gets multiplied by the curve. public float scalar = 1.0f;

AnimationCurve ourCurve;

void Start() { // Get the system and the emission module. myParticleSystem = GetComponent<ParticleSystem>(); emissionModule = myParticleSystem.emission;

// A simple linear curve. ourCurve = new AnimationCurve(); ourCurve.AddKey(0.0f, 0.0f); ourCurve.AddKey(1.0f, 1.0f);

// Apply the curve. emissionModule.rate = new ParticleSystem.MinMaxCurve(scalar, ourCurve);

// In 5 seconds we will modify the curve. Invoke("ModifyCurve", 5.0f); }

void ModifyCurve() { // Add a key to the current curve. ourCurve.AddKey(0.5f, 0.0f);

// Apply the changed curve. emissionModule.rate = new ParticleSystem.MinMaxCurve(scalar, ourCurve); } }
#pragma strict
// This example shows using 2 curves to drive the rate.
public class TwoCurveRateExample extends MonoBehaviour {
	var myParticleSystem: ParticleSystem;
	var emissionModule: ParticleSystem.EmissionModule;
	var ourCurveMin: AnimationCurve;
	var ourCurveMax: AnimationCurve;
	public var scalar: float = 1.0f;
	function Start() {
		// Get the system and the emission module.
		myParticleSystem = GetComponent.<ParticleSystem>();
		emissionModule = myParticleSystem.emission;
		// A horizontal straight line at value 1.
		ourCurveMin = new AnimationCurve();
		ourCurveMin.AddKey(0.0f, 1.0f);
		ourCurveMin.AddKey(1.0f, 1.0f);
		// A horizontal straight line at value 0.5.
		ourCurveMax = new AnimationCurve();
		ourCurveMax.AddKey(0.0f, 0.5f);
		ourCurveMax.AddKey(1.0f, 0.5f);
		// Apply the curves.
		emissionModule.rate = new ParticleSystem.MinMaxCurve(scalar, ourCurveMin, ourCurveMax);
		// In 5 seconds we will modify the curve.
		Invoke("ModifyCurve", 5.0f);
	}
	function ModifyCurve() {
		// Create a "pinch" point.
		ourCurveMin.AddKey(0.5f, 0.7f);
		ourCurveMax.AddKey(0.5f, 0.6f);
		// Apply the changed curve.
		emissionModule.rate = new ParticleSystem.MinMaxCurve(scalar, ourCurveMin, ourCurveMax);
	}
}
using UnityEngine;

// This example shows using 2 curves to drive the rate. public class TwoCurveRateExample : MonoBehaviour { ParticleSystem myParticleSystem; ParticleSystem.EmissionModule emissionModule;

AnimationCurve ourCurveMin; AnimationCurve ourCurveMax;

// We can "scale" the curves with this value. It gets multiplied by the curves. public float scalar = 1.0f;

void Start() { // Get the system and the emission module. myParticleSystem = GetComponent<ParticleSystem>(); emissionModule = myParticleSystem.emission;

// A horizontal straight line at value 1. ourCurveMin = new AnimationCurve(); ourCurveMin.AddKey(0.0f, 1.0f); ourCurveMin.AddKey(1.0f, 1.0f);

// A horizontal straight line at value 0.5. ourCurveMax = new AnimationCurve(); ourCurveMax.AddKey(0.0f, 0.5f); ourCurveMax.AddKey(1.0f, 0.5f);

// Apply the curves. emissionModule.rate = new ParticleSystem.MinMaxCurve(scalar, ourCurveMin, ourCurveMax);

// In 5 seconds we will modify the curve. Invoke("ModifyCurve", 5.0f); }

void ModifyCurve() { // Create a "pinch" point. ourCurveMin.AddKey(0.5f, 0.7f); ourCurveMax.AddKey(0.5f, 0.6f);

// Apply the changed curve. emissionModule.rate = new ParticleSystem.MinMaxCurve(scalar, ourCurveMin, ourCurveMax); } }

Did you find this page useful? Please give it a rating: