0 like 0 dislike
Hi there,

I am trying to alter the DurationInSeconds attribute on a particle layer at runtime -

I see that we now have layer scripts but we currently cannot access the attributes at spawn.

Is there another way to accomplish this using an exposed variable in Unity?

by simonb3d (480 points)

1 Answer

0 like 0 dislike
Best answer

There is no "direct" way to change the duration of a Particle Layer (at least for now).

Here is two workaround I can think of:

  • You could set your Layer Duration to the maximum you need, and in a LayerScript have something like:
    Flux = iif(Age < MyAttributeDuration, 1, 0);
  • Or create a Layer Duration=0 SpawnCoutnMode=TotalParticleCount SpawnCount=1, no Renderers, and just an Evovler Localspace and an Evolver Spawner.
    Then in the Layer's SpawnerScript: Life = MyAttributeDuration;
    And use the Evolver Spawner as your "effective" particles.

Both have some performance overhead. The Evolver Spawner is a bit more complex but might give you more flexibility.

by Jordan (14.6k points)
Thanks Jordan, I will give these a try !