Legacy Documentation: Version 5.5
LanguageEnglish
  • C#
  • JS

Script language

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

ParticleSystem

class in UnityEngine

/

Inherits from:Component

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

Description

Script interface for particle systems (Shuriken).

Shuriken is a powerful and versatile particle system component.

General parameters

The Particle System's general parameters are kept inside a special Main module. These parameters are visible in the Inspector above all the other modules:



In script, these parameters are accessible through ParticleSystem.main.

Module effect multipliers

Every module has special multiplier properties that allow you to change the overall effect of a curve without having to edit the curve itself. These multiplier properties are all named after the curve they affect - for instance ParticleSystem.emission.rateMultiplier controls the overall effect of ParticleSystem.emission.rate in a given system.

Constant value shorthand

Parameters support a shorthand notation for simple constant values. To set a constant value for a parameter, all you need to do is assign a number to it. It is not necessary to create a MinMaxCurve or MinMaxGradient object in the ParticleSystemCurveMode.Constant mode.

For example, instead of:
ParticleSystem.emission.rate = new ParticleSystem.MinMaxCurve(5.0f);
write:
ParticleSystem.emission.rate = 5.0f;

Performance note: When setting properties on particle modules, the settings are passed immediately into native code. This gives the best performance. This means that setting properties on a module struct doesn't set something in script that requires setting back to the particle system; it all happens automatically.

See Also: Particle.

Variables

collisionAccess the particle system collision module.
colorBySpeedAccess the particle system color by lifetime module.
colorOverLifetimeAccess the particle system color over lifetime module.
emissionAccess the particle system emission module.
externalForcesAccess the particle system external forces module.
forceOverLifetimeAccess the particle system force over lifetime module.
inheritVelocityAccess the particle system velocity inheritance module.
isEmittingIs the particle system currently emitting particles? A particle system may stop emitting when its emission module has finished, it has been paused or if the system has been stopped using Stop with the StopEmitting flag. Resume emitting by calling Play.
isPausedIs the particle system paused right now ?
isPlayingIs the particle system playing right now ?
isStoppedIs the particle system stopped right now ?
lightsAccess the particle system lights module.
limitVelocityOverLifetimeAccess the particle system limit velocity over lifetime module.
mainAccess the main particle system settings.
noiseAccess the particle system noise module.
particleCountThe current number of particles (Read Only).
randomSeedOverride the random seed used for the particle system emission.
rotationBySpeedAccess the particle system rotation by speed module.
rotationOverLifetimeAccess the particle system rotation over lifetime module.
shapeAccess the particle system shape module.
sizeBySpeedAccess the particle system size by speed module.
sizeOverLifetimeAccess the particle system size over lifetime module.
subEmittersAccess the particle system sub emitters module.
textureSheetAnimationAccess the particle system texture sheet animation module.
timePlayback position in seconds.
trailsAccess the particle system trails module.
triggerAccess the particle system trigger module.
useAutoRandomSeedControls whether the Particle System uses an automatically-generated random number to seed the random number generator.
velocityOverLifetimeAccess the particle system velocity over lifetime module.

Public Functions

ClearRemove all particles in the particle system.
EmitEmit count particles immediately.
GetCustomParticleDataGet a stream of custom per-particle data.
GetParticlesGet the particles of this particle system.
IsAliveDoes the system have any live particles (or will produce more)?
PausePauses the system so no new particles are emitted and the existing particles are not updated.
PlayStarts the particle system.
SetCustomParticleDataSet a stream of custom per-particle data.
SetParticlesSet the particles of this particle system. size is the number of particles that is set.
SimulateFastforwards the particle system by simulating particles over given period of time, then pauses it.
StopStops playing the particle system using the supplied stop behaviour.

Inherited members

Variables

gameObjectThe game object this component is attached to. A component is always attached to a game object.
tagThe tag of this game object.
transformThe Transform attached to this GameObject.
hideFlagsShould the object be hidden, saved with the scene or modifiable by the user?
nameThe name of the object.

Public Functions

BroadcastMessageCalls the method named methodName on every MonoBehaviour in this game object or any of its children.
CompareTagIs this game object tagged with tag ?
GetComponentReturns the component of Type type if the game object has one attached, null if it doesn't.
GetComponentInChildrenReturns the component of Type type in the GameObject or any of its children using depth first search.
GetComponentInParentReturns the component of Type type in the GameObject or any of its parents.
GetComponentsReturns all components of Type type in the GameObject.
GetComponentsInChildrenReturns all components of Type type in the GameObject or any of its children.
GetComponentsInParentReturns all components of Type type in the GameObject or any of its parents.
SendMessageCalls the method named methodName on every MonoBehaviour in this game object.
SendMessageUpwardsCalls the method named methodName on every MonoBehaviour in this game object and on every ancestor of the behaviour.
GetInstanceIDReturns the instance id of the object.
ToStringReturns the name of the game object.

Static Functions

DestroyRemoves a gameobject, component or asset.
DestroyImmediateDestroys the object obj immediately.
DontDestroyOnLoadMakes the object target not be destroyed automatically when loading a new scene.
FindObjectOfTypeReturns the first active loaded object of Type type.
FindObjectsOfTypeReturns a list of all active loaded objects of Type type.
InstantiateClones the object original and returns the clone.

Operators

boolDoes the object exist?
operator !=Compares if two objects refer to a different object.
operator ==Compares two object references to see if they refer to the same object.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961