mob-sakai/ParticleEffectForUGUI

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.
    image
  • each has 2 children of Particle Systems using recommended UI/Default material, masking disabled
    image
  • Particles themselves emit a single Burst. Renderer seem to be disabled by UIParticles
    image

In general it does not emit anything with the code below.
image
Or maybe emit it but like this:
no_looping_ui
but if during the runtime I switch Particle Systems to looping
looping_ui
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!

I would like to know more about this issue.
Could you please attach a minimal project (included Assets, Packages and ProjectSettings directories) that reproduces the issue?
Of course, you don't need to include any secret assets from your project. Feel free to use free assets instead.

repos