Class ParticleEffect
The particle system instance that plays the particles simulation in the game.
Inherited Members
Assembly: FlaxEngine.dll
File: Engine/Particles/ParticleEffect.h
Syntax
public class ParticleEffect : public Actor
Fields
CustomViewRenderTask
The custom render task used as a view information source (effect will use its render buffers and rendering resolution information for particles simulation).
Declaration
public ScriptingObjectReference<SceneRenderTask> CustomViewRenderTask
Field Value
ScriptingObjectReference<SceneRenderTask>
|
DrawModes
The draw passes to use for rendering this object.
Declaration
public DrawPass DrawModes = DrawPass::Default
Field Value
DrawPass
|
FixedTimestep
The fixed timestep for simulation updates. Used only if UpdateMode is set to FixedTimestep.
Declaration
public float FixedTimestep = 1.0f / 60.0f
Field Value
float
|
Instance
The instance data of the particle system.
Declaration
public ParticleSystemInstance Instance
Field Value
ParticleSystemInstance
|
IsLooping
Determines whether the particle effect should loop when it finishes playing.
Declaration
public bool IsLooping = true
Field Value
bool
|
ParticleSystem
The particle system to play.
Declaration
public AssetReference<ParticleSystem> ParticleSystem
Field Value
AssetReference<ParticleSystem>
|
PlayOnStart
Determines whether the particle effect should play on start.
Declaration
public bool PlayOnStart = true
Field Value
bool
|
SimulationSpeed
The particles simulation speed factor. Scales the particle system update delta time. Can be used to speed up or slow down the particles.
Declaration
public float SimulationSpeed = 1.0f
Field Value
float
|
SortOrder
The object sort order key used when sorting drawable objects during rendering. Use lower values to draw object before others, higher values are rendered later (on top). Can be used to control transparency drawing.
Declaration
public int8 SortOrder = 0
Field Value
int8
|
UpdateMode
The particles simulation update mode. Defines how to update particles emitter.
Declaration
public SimulationUpdateMode UpdateMode = SimulationUpdateMode::Realtime
Field Value
SimulationUpdateMode
|
UpdateWhenOffscreen
If true, the particle simulation will be updated even when an actor cannot be seen by any camera. Otherwise, the simulation will stop running when the actor is off-screen.
Declaration
public bool UpdateWhenOffscreen = true
Field Value
bool
|
UseTimeScale
Determines whether the particle effect should take into account the global game time scale for simulation updates.
Declaration
public bool UseTimeScale = true
Field Value
bool
|
Methods
Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)
Deserializes object from the input stream.
Declaration
public virtual void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override
Parameters
DeserializeStream
stream
The input stream. |
ISerializeModifier
modifier
The deserialization modifier object. Always valid. |
Overrides
Draw(RenderContext& renderContext)
Draws this actor. Called by Scene Rendering service. This call is more optimized than generic Draw (eg. geometry is rendered during all pass types but other actors are drawn only during GBufferFill pass).
Declaration
public virtual void Draw(RenderContext& renderContext) override
Parameters
RenderContext
renderContext
The rendering context. |
Overrides
EndPlay()
Called when removing object from the game.
Declaration
protected virtual void EndPlay() override
Overrides
GetEditorBox()
Gets actor bounding box (single actor, no children included) for editor tools.
Declaration
public virtual BoundingBox GetEditorBox() const override
Returns
BoundingBox
|
Overrides
GetIsPlaying()
Gets whether or not the particle effect is playing.
Declaration
public bool GetIsPlaying() const
Returns
bool
|
GetLastUpdateTime()
Gets the last game time when particle system was updated. Value -1 indicates no previous updates.
Declaration
public float GetLastUpdateTime() const
Returns
float
|
GetParameter(const StringView& emitterTrackName, const Guid& paramId)
Gets the particle parameter.
Declaration
public ParticleEffectParameter* GetParameter(const StringView& emitterTrackName, const Guid& paramId)
Parameters
StringView
emitterTrackName
The emitter track name (in particle system asset). |
Guid
paramId
The emitter parameter ID (in particle emitter asset). |
Returns
ParticleEffectParameter
The effect parameter or null if failed to find. |
GetParameter(const StringView& emitterTrackName, const StringView& paramName)
Gets the particle parameter.
Declaration
public ParticleEffectParameter* GetParameter(const StringView& emitterTrackName, const StringView& paramName)
Parameters
StringView
emitterTrackName
The emitter track name (in particle system asset). |
StringView
paramName
The emitter parameter name (in particle emitter asset). |
Returns
ParticleEffectParameter
The effect parameter or null if failed to find. |
GetParameters()
Gets the effect parameters collection. Those parameters are instanced from the ParticleSystem that contains a linear list of emitters and every emitter has a list of own parameters.
Declaration
public Array<ParticleEffectParameter> GetParameters()
Returns
Array<ParticleEffectParameter>
|
GetParametersOverrides()
Declaration
protected Array<ParticleEffect::ParameterOverride> GetParametersOverrides()
Returns
Array<ParticleEffect::ParameterOverride>
|
GetParametersVersion()
Gets the effect parameters collection version number. It can be used to track parameters changes that occur when particle system or one of the emitters gets reloaded/edited.
Declaration
public uint32 GetParametersVersion() const
Returns
uint32
|
GetParameterValue(const StringView& emitterTrackName, const StringView& paramName)
Gets the particle parameter value.
Declaration
public Variant GetParameterValue(const StringView& emitterTrackName, const StringView& paramName)
Parameters
StringView
emitterTrackName
The emitter track name (in particle system asset). |
StringView
paramName
The emitter parameter name (in particle emitter asset). |
Returns
Variant
The value. |
GetParticlesCount()
Gets the particles count (total). GPU particles count is read with one frame delay (due to GPU execution).
Declaration
public int32 GetParticlesCount() const
Returns
int32
|
GetRenderTask()
Gets the render task to use for particles simulation (eg. depth buffer collisions or view information).
Declaration
public SceneRenderTask* GetRenderTask() const
Returns
SceneRenderTask
|
GetTime()
Gets the current time position of the particle system timeline animation playback (in seconds).
Declaration
public float GetTime() const
Returns
float
|
HasContentLoaded()
Returns true if actor has loaded content.
Declaration
public virtual bool HasContentLoaded() const override
Returns
bool
|
Overrides
OnActiveInTreeChanged()
Called when actor active in tree state gets changed.
Declaration
protected virtual void OnActiveInTreeChanged() override
Overrides
OnDebugDrawSelected()
Draws debug shapes for the selected actor and all child scripts.
Declaration
public virtual void OnDebugDrawSelected() override
Overrides
OnDisable()
Called when actor gets removed from game systems. Occurs on EndPlay event or when actor gets inactivated in hierarchy. Use this event to unregister object from other game system (eg. audio).
Declaration
protected virtual void OnDisable() override
Overrides
OnEnable()
Called when actor gets added to game systems. Occurs on BeginPlay event or when actor gets activated in hierarchy. Use this event to register object to other game system (eg. audio).
Declaration
protected virtual void OnEnable() override
Overrides
OnLayerChanged()
Called when layer gets changed.
Declaration
public virtual void OnLayerChanged() override
Overrides
OnTransformChanged()
Called when actor transform gets changed.
Declaration
protected virtual void OnTransformChanged() override
Overrides
Pause()
Pauses the simulation.
Declaration
public void Pause()
Play()
Plays the simulation.
Declaration
public void Play()
ResetParameters()
Resets the particle system parameters to the default values from asset.
Declaration
public void ResetParameters()
ResetSimulation()
Resets the particles simulation state (clears the instance state data but preserves the instance parameters values).
Declaration
public void ResetSimulation()
Serialize(SerializeStream& stream, const void* otherObj)
Serializes object to the output stream compared to the values of the other object instance (eg. default class object). If other object is null then serialize all properties.
Declaration
public virtual void Serialize(SerializeStream& stream, const void* otherObj) override
Parameters
SerializeStream
stream
The output stream. |
void
otherObj
The instance of the object to compare with and serialize only the modified properties. If null, then serialize all properties. |
Overrides
SetLastUpdateTime(float time)
Sets the last game time when particle system was updated. Value -1 indicates no previous updates.
Declaration
public void SetLastUpdateTime(float time)
Parameters
float
time
|
SetParametersOverrides(const Array<ParticleEffect::ParameterOverride>& value)
Declaration
protected void SetParametersOverrides(const Array<ParticleEffect::ParameterOverride>& value)
Parameters
Array<ParticleEffect::ParameterOverride>
value
|
SetParameterValue(const StringView& emitterTrackName, const StringView& paramName, const Variant& value)
Set the particle parameter value.
Declaration
public void SetParameterValue(const StringView& emitterTrackName, const StringView& paramName, const Variant& value)
Parameters
StringView
emitterTrackName
The emitter track name (in particle system asset). |
StringView
paramName
The emitter parameter name (in particle emitter asset). |
Variant
value
The value to set. |
SetTime(float time)
Sets the current time position of the particle system timeline animation playback (in seconds).
Declaration
public void SetTime(float time)
Parameters
float
time
|
SpawnParticles(int32 count, const StringView& emitterTrackName=String::Empty)
Manually spawns additional particles into the simulation.
Declaration
public void SpawnParticles(int32 count, const StringView& emitterTrackName=String::Empty)
Parameters
int32
count
Amount of particles to spawn. |
StringView
emitterTrackName
Name of the emitter track to spawn particles in. Empty if spawn particles into all tracks. |
Stop()
Stops and resets the simulation.
Declaration
public void Stop()
Sync()
Synchronizes this instance data with the particle system and all emitters data.
Declaration
public void Sync()
UpdateBounds()
Updates the actor bounds.
Declaration
public void UpdateBounds()
UpdateSimulation(bool singleFrame=false)
Performs the full particles simulation update (postponed for the next particle manager update).
Declaration
public void UpdateSimulation(bool singleFrame=false)
Parameters
bool
singleFrame
True if update animation by a single frame only (time time since last engine update), otherwise will update simulation with delta time since last update. |