123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
-
- // =================================
- // Namespaces.
- // =================================
- using UnityEngine;
- // =================================
- // Define namespace.
- // =================================
- namespace MirzaBeig
- {
- namespace ParticleSystems
- {
- // =================================
- // Classes.
- // =================================
-
- public class ParticleSystems : MonoBehaviour
- {
- // =================================
- // Nested classes and structures.
- // =================================
- // =================================
- // Variables.
- // =================================
- public ParticleSystem[] particleSystems { get; set; }
- // Event delegates.
- public delegate void onParticleSystemsDeadEventHandler();
- public event onParticleSystemsDeadEventHandler onParticleSystemsDeadEvent;
- // =================================
- // Functions.
- // =================================
- // ...
- protected virtual void Awake()
- {
- particleSystems = GetComponentsInChildren<ParticleSystem>();
- }
- // ...
- protected virtual void Start()
- {
- }
- // ...
- protected virtual void Update()
- {
- }
- // ...
- protected virtual void LateUpdate()
- {
- if (onParticleSystemsDeadEvent != null)
- {
- if (!isAlive())
- {
- onParticleSystemsDeadEvent();
- }
- }
- }
- // ...
- public void reset()
- {
- //simulate(0.0f, true);
- for (int i = 0; i < particleSystems.Length; i++)
- {
- particleSystems[i].time = 0.0f;
- }
- }
- // ...
- public void play()
- {
- for (int i = 0; i < particleSystems.Length; i++)
- {
- particleSystems[i].Play(false);
- }
- }
- // ...
- public void pause()
- {
- for (int i = 0; i < particleSystems.Length; i++)
- {
- particleSystems[i].Pause(false);
- }
- }
- // ...
- public void stop()
- {
- for (int i = 0; i < particleSystems.Length; i++)
- {
- particleSystems[i].Stop(false);
- }
- }
- // ...
- public void clear()
- {
- for (int i = 0; i < particleSystems.Length; i++)
- {
- particleSystems[i].Clear(false);
- }
- }
- // ...
- public void setLoop(bool loop)
- {
- for (int i = 0; i < particleSystems.Length; i++)
- {
- ParticleSystem.MainModule m = particleSystems[i].main;
- m.loop = loop;
- }
- }
- // ...
- public void setPlaybackSpeed(float speed)
- {
- for (int i = 0; i < particleSystems.Length; i++)
- {
- ParticleSystem.MainModule m = particleSystems[i].main;
- m.simulationSpeed = speed;
- }
- }
- // ...
- public void simulate(float time, bool reset = false)
- {
- for (int i = 0; i < particleSystems.Length; i++)
- {
- particleSystems[i].Simulate(time, false, reset);
- }
- }
- // ...
- public bool isAlive()
- {
- for (int i = 0; i < particleSystems.Length; i++)
- {
- if (particleSystems[i])
- {
- if (particleSystems[i].IsAlive())
- {
- return true;
- }
- }
- }
- return false;
- }
- // ...
- public bool isPlaying(bool checkAll = false)
- {
- if (particleSystems.Length == 0)
- {
- return false;
- }
- else if (!checkAll)
- {
- return particleSystems[0].isPlaying;
- }
- else
- {
- for (int i = 0; i < 0; i++)
- {
- if (!particleSystems[i].isPlaying)
- {
- return false;
- }
- }
- return true;
- }
- }
- // ...
- public int getParticleCount()
- {
- int pcount = 0;
- for (int i = 0; i < particleSystems.Length; i++)
- {
- if (particleSystems[i])
- {
- pcount += particleSystems[i].particleCount;
- }
- }
- return pcount;
- }
- // =================================
- // End functions.
- // =================================
- }
- // =================================
- // End namespace.
- // =================================
- }
- }
- // =================================
- // --END-- //
- // =================================
|