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