GetTriggerParticles
Gets the particles that meet the condition in the particle trigger module.
Read time 2 minutesLast updated 15 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- Assembly: UnityEngine.ParticleSystemModule
GetTriggerParticles(ParticleSystem, ParticleSystemTriggerEventType, List<Particle>)
Gets the particles that meet the condition in the particle trigger module.
public static int GetTriggerParticles(this ParticleSystem ps, ParticleSystemTriggerEventType type, List<ParticleSystem.Particle> particles)
Parameters
Particle system.
Type of trigger to return particles for.
The array of particles matching the trigger event type.
Returns
Type | Description |
|---|---|
| int | Number of particles with this trigger event type. |
Remarks
This method is typically called from OnParticleTrigger in response to a trigger callback.
GetTriggerParticles(ParticleSystem, ParticleSystemTriggerEventType, List<Particle>, ColliderData)
Gets the particles that met a condition in the trigger module, along with the collider data for those particles.
public static int GetTriggerParticles(this ParticleSystem ps, ParticleSystemTriggerEventType type, List<ParticleSystem.Particle> particles, out ParticleSystem.ColliderData colliderData)
Parameters
The particle system to get trigger particles from.
The type of trigger event to get particles for.
The list that the method fills with the particles that match the trigger event type.
The collider data for the particles that match the trigger event type.
Returns
Type | Description |
|---|---|
| int | The number of particles that match the trigger event type. |
Remarks
This method is typically called from OnParticleTrigger in response to a trigger callback. The method writes the matching particles to and returns how many it wrote.
particlesTo get collider data, set ParticleSystem.TriggerModule.colliderQueryMode to ParticleSystemColliderQueryMode.One or ParticleSystemColliderQueryMode.All. If it's set to ParticleSystemColliderQueryMode.Disabled, the method still returns the matching particles, but the collider data contains no colliders for them and Unity logs a warning.
This overload throws an if is ParticleSystemTriggerEventType.Exit or ParticleSystemTriggerEventType.Outside, because collider data isn't available for those event types.
InvalidOperationExceptiontype