Added ability to recognise when "PlayOnAwake" was disabled for a Particle System

Also added three programmatic calls to Play, Pause and Stop the effect.
pull/413/head
Simon (darkside) Jackson 2020-04-19 11:42:58 +01:00
parent 079fbe952f
commit f1fbd9dacd
1 changed files with 24 additions and 2 deletions

View File

@ -25,6 +25,7 @@ namespace UnityEngine.UI.Extensions
private int textureSheetAnimationFrames;
private Vector2 textureSheetAnimationFrameSize;
private ParticleSystemRenderer pRenderer;
private bool isInitialised = false;
private Material currentMaterial;
@ -149,6 +150,12 @@ namespace UnityEngine.UI.Extensions
return;
}
if (!isInitialised && !pSystem.main.playOnAwake)
{
pSystem.Stop(false, ParticleSystemStopBehavior.StopEmittingAndClear);
isInitialised = true;
}
Vector2 temp = Vector2.zero;
Vector2 corner1 = Vector2.zero;
Vector2 corner2 = Vector2.zero;
@ -330,7 +337,7 @@ namespace UnityEngine.UI.Extensions
}
}
void Update()
private void Update()
{
if (!fixedTime && Application.isPlaying)
{
@ -346,7 +353,7 @@ namespace UnityEngine.UI.Extensions
}
}
void LateUpdate()
private void LateUpdate()
{
if (!Application.isPlaying)
{
@ -377,6 +384,21 @@ namespace UnityEngine.UI.Extensions
currentMaterial = null;
currentTexture = null;
}
public void StartParticleEmission()
{
pSystem.Play();
}
public void StopParticleEmission()
{
pSystem.Stop(false, ParticleSystemStopBehavior.StopEmittingAndClear);
}
public void PauseParticleEmission()
{
pSystem.Stop(false, ParticleSystemStopBehavior.StopEmitting);
}
}
#endif
}