CpuParticles2D
A CPU-based 2D particle emitter.
A CPU-based 2D particle emitter.
CPU-based 2D particle node used to create a variety of particle systems and effects.
See also GpuParticles2D, which provides the same functionality with hardware acceleration, but may not run on older devices.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
CpuParticles2DConstructor
public CpuParticles2D();Properties69
AmountProperty
public int Amount { get; set; }Number of particles emitted in one emission cycle.
AngleCurveProperty
public Curve AngleCurve { get; set; }Each particle's rotation will be animated along this Curve. Should be a unit Curve.
AngleMaxProperty
public float AngleMax { get; set; }Maximum initial rotation applied to each particle, in degrees.
AngleMinProperty
public float AngleMin { get; set; }Minimum equivalent of CpuParticles2D.AngleMax.
AngularVelocityCurveProperty
public Curve AngularVelocityCurve { get; set; }Each particle's angular velocity will vary along this Curve. Should be a unit Curve.
AngularVelocityMaxProperty
public float AngularVelocityMax { get; set; }Maximum initial angular velocity (rotation speed) applied to each particle in degrees per second.
AngularVelocityMinProperty
public float AngularVelocityMin { get; set; }Minimum equivalent of CpuParticles2D.AngularVelocityMax.
AnimOffsetCurveProperty
public Curve AnimOffsetCurve { get; set; }Each particle's animation offset will vary along this Curve. Should be a unit Curve.
AnimOffsetMaxProperty
public float AnimOffsetMax { get; set; }Maximum animation offset that corresponds to frame index in the texture. 0 is the first frame, 1 is the last one. See CanvasItemMaterial.ParticlesAnimation.
AnimOffsetMinProperty
public float AnimOffsetMin { get; set; }Minimum equivalent of CpuParticles2D.AnimOffsetMax.
AnimSpeedCurveProperty
public Curve AnimSpeedCurve { get; set; }Each particle's animation speed will vary along this Curve. Should be a unit Curve.
AnimSpeedMaxProperty
public float AnimSpeedMax { get; set; }Maximum particle animation speed. Animation speed of 1 means that the particles will make full 0 to 1 offset cycle during lifetime, 2 means 2 cycles etc.
With animation speed greater than 1, remember to enable CanvasItemMaterial.ParticlesAnimLoop property if you want the animation to repeat.
AnimSpeedMinProperty
public float AnimSpeedMin { get; set; }Minimum equivalent of CpuParticles2D.AnimSpeedMax.
ColorProperty
public Color Color { get; set; }Each particle's initial color. If CpuParticles2D.Texture is defined, it will be multiplied by this color.
ColorInitialRampProperty
public Gradient ColorInitialRamp { get; set; }Each particle's initial color will vary along this Gradient (multiplied with CpuParticles2D.Color).
ColorRampProperty
public Gradient ColorRamp { get; set; }Each particle's color will vary along this Gradient over its lifetime (multiplied with CpuParticles2D.Color).
DampingCurveProperty
public Curve DampingCurve { get; set; }DampingMaxProperty
public float DampingMax { get; set; }The maximum rate at which particles lose velocity. For example value of 100 means that the particle will go from 100 velocity to 0 in 1 second.
DampingMinProperty
public float DampingMin { get; set; }Minimum equivalent of CpuParticles2D.DampingMax.
DirectionProperty
public Vector2 Direction { get; set; }Unit vector specifying the particles' emission direction.
DrawOrderProperty
public CpuParticles2D.DrawOrderEnum DrawOrder { get; set; }Particle draw order.
EmissionColorsProperty
public Color[] EmissionColors { get; set; }Sets the Colors to modulate particles by when using CpuParticles2D.EmissionShapeEnum.Points or CpuParticles2D.EmissionShapeEnum.DirectedPoints.
EmissionNormalsProperty
public Vector2[] EmissionNormals { get; set; }Sets the direction the particles will be emitted in when using CpuParticles2D.EmissionShapeEnum.DirectedPoints.
EmissionPointsProperty
public Vector2[] EmissionPoints { get; set; }Sets the initial positions to spawn particles when using CpuParticles2D.EmissionShapeEnum.Points or CpuParticles2D.EmissionShapeEnum.DirectedPoints.
EmissionRectExtentsProperty
public Vector2 EmissionRectExtents { get; set; }The rectangle's extents if CpuParticles2D.EmissionShape is set to CpuParticles2D.EmissionShapeEnum.Rectangle.
EmissionRingInnerRadiusProperty
public float EmissionRingInnerRadius { get; set; }The ring's inner radius if CpuParticles2D.EmissionShape is set to CpuParticles2D.EmissionShapeEnum.Ring.
EmissionRingRadiusProperty
public float EmissionRingRadius { get; set; }The ring's outer radius if CpuParticles2D.EmissionShape is set to CpuParticles2D.EmissionShapeEnum.Ring.
EmissionShapeProperty
public CpuParticles2D.EmissionShapeEnum EmissionShape { get; set; }Particles will be emitted inside this region.
EmissionSphereRadiusProperty
public float EmissionSphereRadius { get; set; }The sphere's radius if CpuParticles2D.EmissionShape is set to CpuParticles2D.EmissionShapeEnum.Sphere.
EmittingProperty
public bool Emitting { get; set; }Allows new particles to be emitted. false does not delete existing live particles; they remain until their lifetimes end. This is not a full pause or Restart. For OneShot, observe Finished rather than treating Emitting=false as proof that the screen is empty.
ExplosivenessProperty
public float Explosiveness { get; set; }How rapidly particles in an emission cycle are emitted. If greater than 0, there will be a gap in emissions before the next cycle begins.
FixedFpsProperty
public int FixedFps { get; set; }The particle system's frame rate is fixed to a value. For example, changing the value to 2 will make the particles render at 2 frames per second. Note this does not slow down the simulation of the particle system itself.
FractDeltaProperty
public bool FractDelta { get; set; }If true, results in fractional delta calculation which has a smoother particles display effect.
GravityProperty
public Vector2 Gravity { get; set; }Gravity applied to every particle.
HueVariationCurveProperty
public Curve HueVariationCurve { get; set; }Each particle's hue will vary along this Curve. Should be a unit Curve.
HueVariationMaxProperty
public float HueVariationMax { get; set; }Maximum initial hue variation applied to each particle. It will shift the particle color's hue.
HueVariationMinProperty
public float HueVariationMin { get; set; }Minimum equivalent of CpuParticles2D.HueVariationMax.
InitialVelocityMaxProperty
public float InitialVelocityMax { get; set; }Maximum initial velocity magnitude for each particle. Direction comes from CpuParticles2D.Direction and CpuParticles2D.Spread.
InitialVelocityMinProperty
public float InitialVelocityMin { get; set; }Minimum equivalent of CpuParticles2D.InitialVelocityMax.
LifetimeProperty
public double Lifetime { get; set; }Amount of time each particle will exist.
LifetimeRandomnessProperty
public double LifetimeRandomness { get; set; }Particle lifetime randomness ratio.
LinearAccelCurveProperty
public Curve LinearAccelCurve { get; set; }Each particle's linear acceleration will vary along this Curve. Should be a unit Curve.
LinearAccelMaxProperty
public float LinearAccelMax { get; set; }Maximum linear acceleration applied to each particle in the direction of motion.
LinearAccelMinProperty
public float LinearAccelMin { get; set; }Minimum equivalent of CpuParticles2D.LinearAccelMax.
LocalCoordsProperty
public bool LocalCoords { get; set; }Selects simulation space. With true, previously emitted particles follow emitter transforms; with false, they remain in world canvas space when the emitter subsequently moves. Choose before starting the effect and account for visibility bounds separately.
OneShotProperty
public bool OneShot { get; set; }If true, only one emission cycle occurs. If set true during a cycle, emission will stop at the cycle's end.
OrbitVelocityCurveProperty
public Curve OrbitVelocityCurve { get; set; }Each particle's orbital velocity will vary along this Curve. Should be a unit Curve.
OrbitVelocityMaxProperty
public float OrbitVelocityMax { get; set; }Maximum orbital velocity applied to each particle. Makes the particles circle around origin. Specified in number of full rotations around origin per second.
OrbitVelocityMinProperty
public float OrbitVelocityMin { get; set; }Minimum equivalent of CpuParticles2D.OrbitVelocityMax.
ParticleFlagAlignYProperty
public bool ParticleFlagAlignY { get; set; }Align Y axis of particle with the direction of its velocity.
PreprocessProperty
public double Preprocess { get; set; }Particle system starts as if it had already run for this many seconds.
RadialAccelCurveProperty
public Curve RadialAccelCurve { get; set; }Each particle's radial acceleration will vary along this Curve. Should be a unit Curve.
RadialAccelMaxProperty
public float RadialAccelMax { get; set; }Maximum radial acceleration applied to each particle. Makes particle accelerate away from the origin or towards it if negative.
RadialAccelMinProperty
public float RadialAccelMin { get; set; }Minimum equivalent of CpuParticles2D.RadialAccelMax.
RandomnessProperty
public float Randomness { get; set; }Emission lifetime randomness ratio.
ScaleAmountCurveProperty
public Curve ScaleAmountCurve { get; set; }Each particle's scale will vary along this Curve. Should be a unit Curve.
ScaleAmountMaxProperty
public float ScaleAmountMax { get; set; }Maximum initial scale applied to each particle.
ScaleAmountMinProperty
public float ScaleAmountMin { get; set; }Minimum equivalent of CpuParticles2D.ScaleAmountMax.
ScaleCurveXProperty
public Curve ScaleCurveX { get; set; }Each particle's horizontal scale will vary along this Curve. Should be a unit Curve.
CpuParticles2D.SplitScale must be enabled.
ScaleCurveYProperty
public Curve ScaleCurveY { get; set; }Each particle's vertical scale will vary along this Curve. Should be a unit Curve.
CpuParticles2D.SplitScale must be enabled.
SeedProperty
public uint Seed { get; set; }Sets the random seed used by the particle system. Only effective if CpuParticles2D.UseFixedSeed is true.
SpeedScaleProperty
public double SpeedScale { get; set; }Particle system's running speed scaling ratio. A value of 0 can be used to pause the particles.
SplitScaleProperty
public bool SplitScale { get; set; }If true, the scale curve will be split into x and y components. See CpuParticles2D.ScaleCurveX and CpuParticles2D.ScaleCurveY.
SpreadProperty
public float Spread { get; set; }Each particle's initial direction range from +spread to -spread degrees.
TangentialAccelCurveProperty
public Curve TangentialAccelCurve { get; set; }Each particle's tangential acceleration will vary along this Curve. Should be a unit Curve.
TangentialAccelMaxProperty
public float TangentialAccelMax { get; set; }Maximum tangential acceleration applied to each particle. Tangential acceleration is perpendicular to the particle's velocity giving the particles a swirling motion.
TangentialAccelMinProperty
public float TangentialAccelMin { get; set; }Minimum equivalent of CpuParticles2D.TangentialAccelMax.
TextureProperty
public Texture2D Texture { get; set; }Particle texture. If null, particles will be squares.
UseFixedSeedProperty
public bool UseFixedSeed { get; set; }If true, particles will use the same seed for every simulation using the seed defined in CpuParticles2D.Seed. This is useful for situations where the visual outcome should be consistent across replays, for example when using Movie Maker mode.
Methods82
ConvertFromParticlesvoid
public void ConvertFromParticles(Entity particles);Sets this node's properties to match a given GpuParticles2D node with an assigned ParticleProcessMaterial.
| Name | Type | Default |
|---|---|---|
particles | Entity | — |
GetAmountint
public int GetAmount();intGetColorColor
public Color GetColor();ColorGetColorInitialRampGradient
public Gradient GetColorInitialRamp();GradientGetColorRampGradient
public Gradient GetColorRamp();GradientGetDirectionVector2
public Vector2 GetDirection();Vector2GetDrawOrderCpuParticles2D.DrawOrderEnum
public CpuParticles2D.DrawOrderEnum GetDrawOrder();CpuParticles2D.DrawOrderEnumGetEmissionColorsColor[]
public Color[] GetEmissionColors();Color[]GetEmissionNormalsVector2[]
public Vector2[] GetEmissionNormals();Vector2[]GetEmissionPointsVector2[]
public Vector2[] GetEmissionPoints();Vector2[]GetEmissionRectExtentsVector2
public Vector2 GetEmissionRectExtents();Vector2GetEmissionRingInnerRadiusfloat
public float GetEmissionRingInnerRadius();floatGetEmissionRingRadiusfloat
public float GetEmissionRingRadius();floatGetEmissionShapeCpuParticles2D.EmissionShapeEnum
public CpuParticles2D.EmissionShapeEnum GetEmissionShape();CpuParticles2D.EmissionShapeEnumGetEmissionSphereRadiusfloat
public float GetEmissionSphereRadius();floatGetExplosivenessRatiofloat
public float GetExplosivenessRatio();floatGetFixedFpsint
public int GetFixedFps();intGetFractionalDeltabool
public bool GetFractionalDelta();boolGetGravityVector2
public Vector2 GetGravity();Vector2GetLifetimedouble
public double GetLifetime();doubleGetLifetimeRandomnessdouble
public double GetLifetimeRandomness();doubleGetOneShotbool
public bool GetOneShot();boolGetParamCurveCurve
public Curve GetParamCurve(CpuParticles2D.Parameter param);Returns the Curve of the parameter specified by CpuParticles2D.Parameter.
| Name | Type | Default |
|---|---|---|
param | CpuParticles2D.Parameter | — |
CurveGetParamMaxfloat
public float GetParamMax(CpuParticles2D.Parameter param);Returns the maximum value range for the given parameter.
| Name | Type | Default |
|---|---|---|
param | CpuParticles2D.Parameter | — |
floatGetParamMinfloat
public float GetParamMin(CpuParticles2D.Parameter param);Returns the minimum value range for the given parameter.
| Name | Type | Default |
|---|---|---|
param | CpuParticles2D.Parameter | — |
floatGetParticleFlagbool
public bool GetParticleFlag(CpuParticles2D.ParticleFlags particleFlag);Returns the enabled state of the given particle flag.
| Name | Type | Default |
|---|---|---|
particleFlag | CpuParticles2D.ParticleFlags | — |
boolGetPreProcessTimedouble
public double GetPreProcessTime();doubleGetRandomnessRatiofloat
public float GetRandomnessRatio();floatGetScaleCurveXCurve
public Curve GetScaleCurveX();CurveGetScaleCurveYCurve
public Curve GetScaleCurveY();CurveGetSeeduint
public uint GetSeed();uintGetSpeedScaledouble
public double GetSpeedScale();doubleGetSplitScalebool
public bool GetSplitScale();boolGetSpreadfloat
public float GetSpread();floatGetTextureTexture2D
public Texture2D GetTexture();Texture2DGetUseFixedSeedbool
public bool GetUseFixedSeed();boolGetUseLocalCoordinatesbool
public bool GetUseLocalCoordinates();boolIsEmittingbool
public bool IsEmitting();boolRequestParticlesProcess2 overloads
public void RequestParticlesProcess(float processTime);Requests the particles to process for extra process time during a single frame.
process_time defines the time that the particles will process while emitting is on. process_time_residual defines the time that particles will process with emitting turned off for the simulation. When combined with CpuParticles2D.SpeedScale set to 0.0, this is useful to be able to seek a particle system timeline.
| Name | Type | Default |
|---|---|---|
processTime | float | — |
public void RequestParticlesProcess(float processTime, float processTimeResidual = 0f);Requests the particles to process for extra process time during a single frame.
process_time defines the time that the particles will process while emitting is on. process_time_residual defines the time that particles will process with emitting turned off for the simulation. When combined with CpuParticles2D.SpeedScale set to 0.0, this is useful to be able to seek a particle system timeline.
| Name | Type | Default |
|---|---|---|
processTime | float | — |
processTimeResidual | float | 0f |
Restart2 overloads
public void Restart();Restarts the particle system. Use Restart(bool keepSeed) for explicit seed control. Restart differs from merely setting Emitting=true and begins the effect again.
public void Restart(bool keepSeed = false);Resets simulation state and enables emission. Seed is retained when keepSeed=true or UseFixedSeed=true; a new random value is selected only when both are false. The image changes after processing/rendering a frame.
| Name | Type | Default |
|---|---|---|
keepSeed | bool | false |
keepSeedtrue retains the current seed. false does not force a new seed when UseFixedSeed is already true. Keeping a seed does not guarantee identical pixels across CPU/GPU implementations, devices or configurations.
SetAmountvoid
public void SetAmount(int amount);| Name | Type | Default |
|---|---|---|
amount | int | — |
SetColorvoid
public void SetColor(Color color);| Name | Type | Default |
|---|---|---|
color | Color | — |
SetColorInitialRampvoid
public void SetColorInitialRamp(Gradient ramp);| Name | Type | Default |
|---|---|---|
ramp | Gradient | — |
SetColorRampvoid
public void SetColorRamp(Gradient ramp);| Name | Type | Default |
|---|---|---|
ramp | Gradient | — |
SetDirectionvoid
public void SetDirection(Vector2 direction);| Name | Type | Default |
|---|---|---|
direction | Vector2 | — |
SetDrawOrdervoid
public void SetDrawOrder(CpuParticles2D.DrawOrderEnum order);| Name | Type | Default |
|---|---|---|
order | CpuParticles2D.DrawOrderEnum | — |
SetEmissionColors2 overloads
public void SetEmissionColors(Color[] array);| Name | Type | Default |
|---|---|---|
array | Color[] | — |
public void SetEmissionColors(ReadOnlySpan<Color> array);| Name | Type | Default |
|---|---|---|
array | ReadOnlySpan<Color> | — |
SetEmissionNormals2 overloads
public void SetEmissionNormals(Vector2[] array);| Name | Type | Default |
|---|---|---|
array | Vector2[] | — |
public void SetEmissionNormals(ReadOnlySpan<Vector2> array);| Name | Type | Default |
|---|---|---|
array | ReadOnlySpan<Vector2> | — |
SetEmissionPoints2 overloads
public void SetEmissionPoints(Vector2[] array);| Name | Type | Default |
|---|---|---|
array | Vector2[] | — |
public void SetEmissionPoints(ReadOnlySpan<Vector2> array);| Name | Type | Default |
|---|---|---|
array | ReadOnlySpan<Vector2> | — |
SetEmissionRectExtentsvoid
public void SetEmissionRectExtents(Vector2 extents);| Name | Type | Default |
|---|---|---|
extents | Vector2 | — |
SetEmissionRingInnerRadiusvoid
public void SetEmissionRingInnerRadius(float innerRadius);| Name | Type | Default |
|---|---|---|
innerRadius | float | — |
SetEmissionRingRadiusvoid
public void SetEmissionRingRadius(float radius);| Name | Type | Default |
|---|---|---|
radius | float | — |
SetEmissionShapevoid
public void SetEmissionShape(CpuParticles2D.EmissionShapeEnum shape);| Name | Type | Default |
|---|---|---|
shape | CpuParticles2D.EmissionShapeEnum | — |
SetEmissionSphereRadiusvoid
public void SetEmissionSphereRadius(float radius);| Name | Type | Default |
|---|---|---|
radius | float | — |
SetEmittingvoid
public void SetEmitting(bool emitting);| Name | Type | Default |
|---|---|---|
emitting | bool | — |
SetExplosivenessRatiovoid
public void SetExplosivenessRatio(float ratio);| Name | Type | Default |
|---|---|---|
ratio | float | — |
SetFixedFpsvoid
public void SetFixedFps(int fps);| Name | Type | Default |
|---|---|---|
fps | int | — |
SetFractionalDeltavoid
public void SetFractionalDelta(bool enable);| Name | Type | Default |
|---|---|---|
enable | bool | — |
SetGravityvoid
public void SetGravity(Vector2 accelVec);| Name | Type | Default |
|---|---|---|
accelVec | Vector2 | — |
SetLifetimevoid
public void SetLifetime(double secs);| Name | Type | Default |
|---|---|---|
secs | double | — |
SetLifetimeRandomnessvoid
public void SetLifetimeRandomness(double random);| Name | Type | Default |
|---|---|---|
random | double | — |
SetOneShotvoid
public void SetOneShot(bool enable);| Name | Type | Default |
|---|---|---|
enable | bool | — |
SetParamCurvevoid
public void SetParamCurve(CpuParticles2D.Parameter param, Curve curve);Sets the Curve of the parameter specified by CpuParticles2D.Parameter. Should be a unit Curve.
| Name | Type | Default |
|---|---|---|
param | CpuParticles2D.Parameter | — |
curve | Curve | — |
SetParamMaxvoid
public void SetParamMax(CpuParticles2D.Parameter param, float value);Sets the maximum value for the given parameter.
| Name | Type | Default |
|---|---|---|
param | CpuParticles2D.Parameter | — |
value | float | — |
SetParamMinvoid
public void SetParamMin(CpuParticles2D.Parameter param, float value);Sets the minimum value for the given parameter.
| Name | Type | Default |
|---|---|---|
param | CpuParticles2D.Parameter | — |
value | float | — |
SetParticleFlagvoid
public void SetParticleFlag(CpuParticles2D.ParticleFlags particleFlag, bool enable);Enables or disables the given particle flag.
| Name | Type | Default |
|---|---|---|
particleFlag | CpuParticles2D.ParticleFlags | — |
enable | bool | — |
SetPreProcessTimevoid
public void SetPreProcessTime(double secs);| Name | Type | Default |
|---|---|---|
secs | double | — |
SetRandomnessRatiovoid
public void SetRandomnessRatio(float ratio);| Name | Type | Default |
|---|---|---|
ratio | float | — |
SetScaleCurveXvoid
public void SetScaleCurveX(Curve scaleCurve);| Name | Type | Default |
|---|---|---|
scaleCurve | Curve | — |
SetScaleCurveYvoid
public void SetScaleCurveY(Curve scaleCurve);| Name | Type | Default |
|---|---|---|
scaleCurve | Curve | — |
SetSeedvoid
public void SetSeed(uint seed);| Name | Type | Default |
|---|---|---|
seed | uint | — |
SetSpeedScalevoid
public void SetSpeedScale(double scale);| Name | Type | Default |
|---|---|---|
scale | double | — |
SetSplitScalevoid
public void SetSplitScale(bool splitScale);| Name | Type | Default |
|---|---|---|
splitScale | bool | — |
SetSpreadvoid
public void SetSpread(float spread);| Name | Type | Default |
|---|---|---|
spread | float | — |
SetTexturevoid
public void SetTexture(Texture2D texture);| Name | Type | Default |
|---|---|---|
texture | Texture2D | — |
SetUseFixedSeedvoid
public void SetUseFixedSeed(bool useFixedSeed);| Name | Type | Default |
|---|---|---|
useFixedSeed | bool | — |
SetUseLocalCoordinatesvoid
public void SetUseLocalCoordinates(bool enable);| Name | Type | Default |
|---|---|---|
enable | bool | — |
Signals and events1
FinishedEvent
public event Action Finished;Emitted when all active particles have finished processing. When CpuParticles2D.OneShot is disabled, particles will process continuously, so this is never emitted.
CpuParticles2D.DrawOrderEnum
| Value | Description |
|---|---|
Index = 0 | Particles are drawn in the order emitted. |
Lifetime = 1 | Particles are drawn in order of remaining lifetime. In other words, the particle with the highest lifetime is drawn at the front. |
CpuParticles2D.EmissionShapeEnum
| Value | Description |
|---|---|
DirectedPoints = 5 | Particles will be emitted at a position chosen randomly among |
Max = 7 | Represents the size of the |
Point = 0 | All particles will be emitted from a single point. |
Points = 4 | Particles will be emitted at a position chosen randomly among |
Rectangle = 3 | Particles will be emitted in the area of a rectangle. |
Ring = 6 | Particles will be emitted in the area of a ring parameterized by its outer and inner radius. |
Sphere = 1 | Particles will be emitted in the volume of a sphere flattened to two dimensions. |
SphereSurface = 2 | Particles will be emitted on the surface of a sphere flattened to two dimensions. |
CpuParticles2D.Parameter
CpuParticles2D.ParticleFlags
| Value | Description |
|---|---|
AlignYToVelocity = 0 | Use with |
DisableZ = 2 | Present for consistency with 3D particle nodes, not used in 2D. |
Max = 3 | Represents the size of the |
RotateY = 1 | Present for consistency with 3D particle nodes, not used in 2D. |