mob-sakai / ParticleEffectForUGUI

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

Timeline Signal Emitter can't stop a UIParticle using ParticleSystem.Stop() #341

Open CharlieScarver opened 1 week ago

CharlieScarver commented 1 week ago

Describe the bug A Signal Emitter from the timeline to Stop any UIParticles using the ParticleSystem.Stop() method will not work. Only a Signal using UIParticle.Stop() will work (but note that this will also stop any other particle systems nested under that UIParticle object, if there are any). I believe this is probably a bug.

Sample Scene, Timeline, Signal and Particle: Assets.zip

To Reproduce Steps to reproduce the behavior:

  1. Create a new Unity Project and add the UIParticle package via the git link and the TextMeshPro package
  2. Create a new Game Object "Director" and add a PlayableDirector component to it
  3. Create a new TimelineAsset for that object and assign it to the Playable field
  4. Create a new UI Canvas
  5. Create a new GameObject "UI Particle" under the Canvas and add the UIParticle component to it
  6. Create a new GameObject "Particles" under the UIParticle object and add a ParticleSystem component to it
  7. Disable the Particles object
  8. Click on the Director object and open the timeline editor to edit the timeline asset
  9. In the Timeline editor add a new Control Track and drag the Particles object on it (or just drag the object on the timeline)
  10. Create a new Signal track and drag the Particles object as the Signal Receiver object on the left side
  11. Right click in the middle of the control track (should be around 300 frames so middle would be frame 150) and choose "Add Signal Emitter"
  12. Create a new Signal Asset called "Stop Particles" and when prompted add Signal Receiver components to the Particles object
  13. Click on the Signal Emitter on the timeline and add a new Signal Reaction in the Signal Receiver segment in the inspector window on the right
  14. Choose "Editor And Runtime" and "ParticleSystem > Stop()" method
  15. Create a new Button under the UI Canvas and add an OnClick event to it that calls the "PlayableDirector > Play()" method of the Director object
  16. Save the scene
  17. If you now play the game and click the button to trigger the timeline, you will notice that the particle system doesn't stop emitting in the middle of the timeline duration but instead keeps playing until the end and then just disappears when the Particles object is reverted to its disabled state.
  18. If you then stop the game, go to the Signal Emitter on the timeline and add a new reaction that targets the "UI Particle" object and calls "UIParticle > Stop()" method, save and play again, you will notice that the particle system stops emitting in the middle of the timeline.

Expected behavior Since the "Usage" section of the UIParticle readme states that particles can be controlled using either methods (ParticleSystem > Stop() and UIParticle > Stop()) I believe this is probably a bug. Took me quite a while to realize why my ParticleSystems were not stopping 😅

Screenshots Sample Scene, Timeline, Signal and Particle: Assets.zip

Environment (please complete the following information):

mob-sakai commented 15 hours ago

Thank you for your reporting!