Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 issues: 1) Scaling Particle System puts prewarmed particles in wrong location and 2) Sub-emitted particles in wrong location OnDeath #235

Closed
topher-mcbearslayer opened this issue Nov 11, 2022 · 10 comments
Assignees
Labels
bug Something isn't working released

Comments

@topher-mcbearslayer
Copy link

Describe the bug
Hi mob-sakai! I've been sponsoring you for the last year or so and very appreciative of your library. Running the latest UI Particle, however, I have two issues and hoping you could take a look.

Two bugs:

  1. When scaling a Particle System, it incorrectly places the pre-warmed particles in the wrong location. If you do NOT scale the Particle System, the prewarmed particles are correctly placed. This is an issue that was fixed in UI Particle 3.4 but has re-surfaced.

  2. Fireworks Particle System sub-emitted explosion is being placed in incorrect location. Explosion is created OnDeath of parent particle. This used to work in UI Particle 3 but is not working in latest. Works in Editor, but not in Play Mode or on device.

To Reproduce
Steps to reproduce the behavior:

  1. Download my attached sample project.
  2. Use the buttons to create scaled and unscaled smoke particle emitters, notice the scaled particles prewarm in the incorrect location.
  3. Observe that the fireworks particle sub-emitted particles (the explosion) are created in the incorrect location.

Expected behavior
Scaled and unscaled particles should place their prewarmed particles in the correct locations. Sub-emitted particles should be placed in correct position.

Screenshots
image
See attached sample project.

Environment (please complete the following information):

  • Version 4.1.7
  • Platform: Windows (Editor)
  • Unity version: 2021.3.12f1
  • Build options: N/A

Additional context
ParticleTestv2.zip

@topher-mcbearslayer topher-mcbearslayer added the bug Something isn't working label Nov 11, 2022
@topher-mcbearslayer
Copy link
Author

Are you still out there, @mob-sakai? :(

@mob-sakai
Copy link
Owner

Sorry for my late reply and thank you for your reporting!
I will test the project later.

@topher-mcbearslayer
Copy link
Author

Any luck @mob-sakai ?

@PeterBacall
Copy link

PeterBacall commented Feb 16, 2023

Sorry, this might not be helpful, but found some other bugs relating to scaling. I don’t know if the UI Particle is supposed to work with “Screen Space - Overlay”, but it has some bugs on that mode. For example when scaling the UI (switching from 1080p to 4K), the Shapes of the Particle System remain their original size, they probably should’ve scaled with the UI etc. It also has the bugs with particles not getting emitted from the correct location (sometimes).

@topher-mcbearslayer
Copy link
Author

Note for anyone having these issues. I reverted back to latest of version 3 (3.3.12) and no more issues. At some point in version 4 these issues started.

@Dongurea
Copy link

Dongurea commented Apr 7, 2023

For Unity 2021.3.20f1, It occurs. I downgraded it for version 3.3.12 as topher-mcbearslayer said. And this issue disappears now.

@Dongurea
Copy link

Dongurea commented Apr 8, 2023

I downgraded to version 3, but I had to restore to version 4 due to some features and effects design.
However, the errors in version 4 still persisted, so I modified some of the version 4 scripts to solve the problem.
I hope this will be helpful for users who have similar situations.

Here are the situations, configurations, and other conditions that I resolved:

Bug situation and solution

  • (!) Caution: My solution may not be perfect! In particular, I have not tested whether the solution affects optimization. However, at least the issue of particles being incorrectly rendered has been resolved.

Bug Description:

The problem is that the position of the rendered particles is incorrectly set when the application is played.

  1. The particles are displayed correctly when Application.isPlaying is false.
  2. When Application.isPlaying is true and the resolution is changed, the particle position is incorrectly rendered.
  3. The size of the rendered particles is normal.
  4. The problem is related to the Shape of the ParticleSystem, and the initial position of the particles is incorrectly set.

Environment:

  1. UI Particle version: 4.1.7
  2. Unity version: 2023.3.20f1
  3. Platform: Windows (Unity Editor), Android

Solution:

  1. Open the 'UIParticleRenderer.cs' file.
  2. Comment out the following code in 'public void UpdateMesh(Camera bakeCamera)'.
#if UNITY_EDITOR
                if (!Application.isPlaying)
                {
                    SimulateForEditor(psPos - _prevPsPos, scale);
                }
                else
#endif
                {
                    ResolveResolutionChange(psPos, scale);
                    Simulate(scale, _parent.isPaused || _delay);

                    if (_delay && !_parent.isPaused)
                    {
                        Simulate(scale, _parent.isPaused);
                    }

                    // When the ParticleSystem simulation is complete, stop it.
                    if (!main.loop && main.duration <= _particleSystem.time && (_particleSystem.IsAlive() || _particleSystem.particleCount == 0))
                    {
                        _particleSystem.Stop(false);
                    }
                }

Caution when using the solution:

  1. If the simulationSpace of the ParticleSystem is set to world, it may not work properly.
  2. If the number of particles generated by the ParticleSystem is changed every time it is played, it may not work properly.
    • If the number of particles is changed every time it is played, the code related to _particleSystem.GetParticles() is necessary, so you should NOT comment out the entire code, but modify it to fit your own situation.

Note : Also, the code that I asked to comment out contains several other features that I did not mention, so if there are any features in the commented-out code that are needed, they should be modified to fit one's own situation. In my case, I did not need any of those features, so I commented out the entire code.

@topher-mcbearslayer
Copy link
Author

This is a great lead, thank you @Dongurea. I'll try to update back to v4 and comment out the same parts you did.

@JonathanVorich
Copy link

Same Issue! The solution of @Dongurea fixed my problem, but broke some particles in other places, so its not for any use for me. Will there be a fix soon @mob-sakai ??? Would be really really helpful.

github-actions bot pushed a commit that referenced this issue Aug 18, 2023
# [4.2.0](4.1.7...4.2.0) (2023-08-18)

### Bug Fixes

* assertion 'ps->array_size()' in UpdateMesh() when using trails of type ribbon ([f75fcce](f75fcce)), closes [#241](#241)
* built-in shaders are no longer supported ([c2119c1](c2119c1)), closes [#233](#233) [#257](#257)
* crash occurs when too many vertices are rendered ([723a04d](723a04d))
* error: SerializedObject target has been destroyed ([e930516](e930516)), closes [#267](#267)
* excessive particle emitted on move ParticleSystem for local space simulation and emission over distance ([2fe0bde](2fe0bde)), closes [#265](#265)
* fix typos ([52f2ef1](52f2ef1))
* generated GameObject will be named '[generated] *' ([9b2e5c1](9b2e5c1))
* inactive ParticleSystems are removed from the list on refresh ([4851a18](4851a18))
* mesh sharing not working ([8b4ca1a](8b4ca1a)), closes [#236](#236)
* nullptr exceptions when using nested UIParticle components in hierarchy ([e67e948](e67e948)), closes [#246](#246)
* nullReferenceException after copy-n-paste ([425aad0](425aad0)), closes [#258](#258)
* remove unnecessary per-frame allocation. ([e92b514](e92b514))
* scaling ParticleSystem puts prewarmed particles in wrong location ([fb31db4](fb31db4)), closes [#235](#235)
* sub-emitters option is not work in editor playing ([b308b26](b308b26)), closes [#231](#231)
* the camera under UIParticle will be assigned as _orthoCamera ([c42f8c8](c42f8c8))
* UIParticleAttractor attracts the particles at wrong position when in RelativeMode ([68d9925](68d9925)), closes [#262](#262)

### Features

* 'AbsoluteMode' option is renamed to 'PositionMode' ([67eff61](67eff61))
* 'AutoScaling' option will be imported from 'IgnoreCanvasScale' (for v3.x) ([4103041](4103041))
* add 'AutoScaling' option for UIParticle ([35325c8](35325c8))
* add 'UpdateMode' option for UIParticleAttractor ([903f702](903f702)), closes [#250](#250)
* add particle system getter and setter for attractor ([a4bcf93](a4bcf93)), closes [#253](#253)
* add public properties for UIParticleAttractor ([392ab6d](392ab6d)), closes [#253](#253)
* add Start/StopEmission API for UIParticle ([e499836](e499836)), closes [#240](#240)
@github-actions
Copy link

🎉 This issue has been resolved in version 4.2.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

No branches or pull requests

5 participants