-
Notifications
You must be signed in to change notification settings - Fork 0
ParticleSystem Extensions
This utility library, part of the ParticleSystemExtensions namespace, provides extension methods for Unity's ParticleSystem class, offering additional functionality for obtaining information about the particle system.
Gets the duration of the particle system. If allowLoop is set to false and the particle system is looping, it returns -1.
// Example usage
ParticleSystem myParticleSystem = /* Instantiate or reference a ParticleSystem */;
float duration = myParticleSystem.GetDuration();
Debug.Log($"Duration of the ParticleSystem: {duration} seconds");Parameters:
-
particle(ParticleSystem): The particle system to get the duration from. -
allowLoop(bool): Whether to allow looping. Default is false.
Returns:
- float: The duration of the particle system. If
allowLoopis false and the particle system is looping, returns -1.
Enables or disables the emission of particles in a ParticleSystem.
ParticleSystem myParticleSystem = GetComponent<ParticleSystem>();
myParticleSystem.SetActiveEmission(true);Parameters:
-
particleSystem: The ParticleSystem instance to enable or disable emission. -
enabled:trueto enable emission,falseto disable.
This method is an extension for the Unity ParticleSystem class in the Unity.Runtime namespace. It allows you to easily enable or disable the emission of particles in a given ParticleSystem.
Example:
ParticleSystem myParticleSystem = GetComponent<ParticleSystem>();
myParticleSystem.SetActiveEmission(true);Gets the constant maximum emission rate of particles in a ParticleSystem.
ParticleSystem myParticleSystem = GetComponent<ParticleSystem>();
float currentEmissionRate = myParticleSystem.GetEmissionRate();Parameters:
-
particleSystem: The ParticleSystem instance to get the emission rate from.
Returns:
-
float: The constant maximum emission rate of particles.
Sets the constant maximum emission rate of particles in a ParticleSystem.
ParticleSystem myParticleSystem = GetComponent<ParticleSystem>();
myParticleSystem.SetEmissionRate(20.0f);Parameters:
-
particleSystem: The ParticleSystem instance to set the emission rate. -
emissionRate: The new constant maximum emission rate of particles.