Better handling stopping/resetting non-looping effect.
This commit is contained in:
@@ -283,11 +283,8 @@ void ParticleEffect::UpdateSimulation(bool singleFrame)
|
||||
|
||||
void ParticleEffect::Play()
|
||||
{
|
||||
// Reset simulation when play is called and particle system is time is complete - ex. if IsLooping is false and simulation is complete
|
||||
if (!IsLooping && Instance.Time >= (float)ParticleSystem->DurationFrames / ParticleSystem->FramesPerSecond)
|
||||
ResetSimulation();
|
||||
|
||||
_isPlaying = true;
|
||||
_isStopped = false;
|
||||
}
|
||||
|
||||
void ParticleEffect::Pause()
|
||||
@@ -297,6 +294,7 @@ void ParticleEffect::Pause()
|
||||
|
||||
void ParticleEffect::Stop()
|
||||
{
|
||||
_isStopped = true;
|
||||
_isPlaying = false;
|
||||
ResetSimulation();
|
||||
}
|
||||
@@ -452,7 +450,7 @@ void ParticleEffect::Update()
|
||||
void ParticleEffect::UpdateExecuteInEditor()
|
||||
{
|
||||
// Auto-play in Editor
|
||||
if (!Editor::IsPlayMode)
|
||||
if (!Editor::IsPlayMode && !_isStopped)
|
||||
{
|
||||
_isPlaying = true;
|
||||
Update();
|
||||
|
||||
@@ -185,6 +185,7 @@ private:
|
||||
Array<ParticleEffectParameter> _parameters; // Cached for scripting API
|
||||
Array<ParameterOverride> _parametersOverrides; // Cached parameter modifications to be applied to the parameters
|
||||
bool _isPlaying = false;
|
||||
bool _isStopped = false;
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
|
||||
@@ -1318,8 +1318,8 @@ void ParticlesSystem::Job(int32 index)
|
||||
emitterInstance.Buffer = nullptr;
|
||||
}
|
||||
}
|
||||
// Set is playing to false because it is not playing anymore.
|
||||
effect->Pause();
|
||||
// Stop playing effect.
|
||||
effect->Stop();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user