mob-sakai / ParticleEffectForUGUI

Render particle effect in UnityUI(uGUI). Maskable, sortable, and no extra Camera/RenderTexture/Canvas.
MIT License
4.42k stars 625 forks source link

Prewarm doesn't work(?) #339

Open PeterBacall opened 4 weeks ago

PeterBacall commented 4 weeks ago

Describe the bug Prewarm doesn't seem to work? I have a disabled UI window that contains a particle system. Whenever I enable the UI window, the particle system restarts, ignoring "Prewarm" toggle in the Particle System,.

Expected behavior When I enable the UI window, I want the particle system to be prewarmed, meaning looping particles have already filled had some time to accumulate (as if emitted for one loop cycle), and are not starting from the beginning.

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

mob-sakai commented 4 weeks ago

Thank you for your reporting! The issue is not reproduced on my environment... 2024-11-02 9.17.54.webm

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

PeterBacall commented 4 weeks ago

First of all, never thanked you for creating such a great asset, just wanted to let you know that. All the hard work is really appreciated. Thank you!

Back to topic, funnily I can't reproduce the issue in a new project, seems to be something very specific with my project (which is very big), not sure what to do. I'll attach a video if that helps. In the beginning of the video I press "Play" in the Particle System panel, which makes restart, "Prewarm" seems to work. Later in the video I disable the game object and enable it again, the Particle System restarts. This does not reproduce in a new/empty project. So probably a issue on my end.

https://github.com/user-attachments/assets/139db643-6438-4704-a4ff-f41a04d3f55d

mob-sakai commented 4 weeks ago

I have a similar experience, so I’d like you to try the following:

  1. Click Game Object > UI > Particle System to place a new UI particle in the UI window.
  2. Enable prewarm on the Particle System.
  3. When activated, does prewarm work?

If it works, then it’s a Unity bug.
Try creating a new particle system and copying over the properties.

PeterBacall commented 3 weeks ago

I have a similar experience, so I’d like you to try the following:

  1. Click Game Object > UI > Particle System to place a new UI particle in the UI window.
  2. Enable prewarm on the Particle System.
  3. When activated, does prewarm work?

If it works, then it’s a Unity bug. Try creating a new particle system and copying over the properties.

I found the issue, if the “Duration” is set to 1 (or some other low value like 2), while Start Lifetime is set to a higher value, like 5. Prewarm no longer work. Now, if Duration is set to 2.5, and Start Lifetime is set to 5, with Prewarm enabled... it starts halfway through the cycle, and only if Duration is set to 5, it will start “Prewarmed”, meaning a full cycle has been played.

Copying the Particle System to a new particle system would not work.

  1. Create new ui particle system
  2. Set Duration to 1, leave Start Lifetime at 5, and enable Prewarm
  3. Play, notice how it starts from the beginning.
  4. Now set Duration to 2.5
  5. Play, notice how it starts from the middle of the cycle

Conclusion/Solution: When Prewarm is enabled, Duration has to be the same value as Start Lifetime for it to work.

mob-sakai commented 3 weeks ago

Wow, that's interesting. Thank you for your research. :+1: