Only getting correct behavior on subsequent loops
Braza opened this issue · 3 comments
Hi! I try to integrate the system for coins rewards. I think what I am doing is pretty basic:
- added few instances of UIParticles prefabs to the scene to handle different instances of coin bursts. They are children of a separate canvas in overlay mode to control order as needed.
- each has 2 children of Particle Systems using recommended UI/Default material, masking disabled
- Particles themselves emit a single Burst. Renderer seem to be disabled by UIParticles
In general it does not emit anything with the code below.
Or maybe emit it but like this:
but if during the runtime I switch Particle Systems to looping
notice the 1st burst goes wrong, likely in the game space, not UI space
Expected behavior
I'd expect that UIParticles.Play would emit burst particles as configured in the PS.
Also I'd expect that behavior would not depend on iteration number.
Environment (please complete the following information):
- Version 4.9.1
- Platform: Editor Windows
- Unity version: 2022.3.40f1
- Build options: IL2CPP, .Net 4.x, URP, 2D
I got things working by adding SetDirty and RefreshParticles before the Play, also added StartEmission at the end. No idea which item helps, so any suggestions how to make it in a clean way are appreciated. Or we can close this one.
freeParticleSystem.transform.position = pos;
freeParticleSystem.SetAllDirty();
freeParticleSystem.RefreshParticles();
freeParticleSystem.Play();
freeParticleSystem.StartEmission();
Thank you for your reporting!