mob-sakai/ParticleEffectForUGUI

Particles spawn too close to the camera

MihaMarkovi opened this issue ยท 6 comments

Unity version: 2021.2.20f1
Package version: 4.9.0

Hello! I have encountered the problem with particles spawning too close to the camera as shown on the picture below. In this example, Auto Scaling mode is set to "UI Particle".
particles

When I set Auto Scaling Mode to "None", that seems to fix the issue, but particles are now way too large.
particles2

Am I doing something wrong? Thanks in advance.

Thank you for your reporting!
Could you please attach a minimal project (included Assets, Packages and ProjectSettings directories) that reproduces the issue?

repos

@MihaMarkovi
In haste, here is the workaround:

// Assets/Games/Test/Scripts/LuckyChip.cs (178)
// _particles2DCircle.Play();
// _particles2DStars.Play();
var uip = GetComponentInChildren<UIParticle>();
uip.enabled = false;
uip.enabled = true;
_particles2DCircle.Simulate(0);
_particles2DStars.Simulate(0);
await MoveChipToPosition(_initialPosition, playPlaceAnimation);
...
fixed.webm

Thanks for fix @mob-sakai !
I have implemented your solution, but Simulate method resets particles when you call it multiple times, which I don't want, so I replaced it with Play. When using Play method, particles are still drawn in front of the camera, but no I at least dont see them, so that works fine for me.
Do you by any chance know when this will be fixed?

Unfortunately, a fundamental fix is hard to find.
A better solution is to control emissions with ParticleSystem.emission.enabled=true/false instead of ParticleSystem.Play()/Stop().

ParticleSystem.main.looping = true;
ParticleSystem.main.playOnAwake = true;
ParticleSystem.emmision.enabled = false;

// _particles2DCircle.Play();
// _particles2DStars.Play();
GetComponentInChildren<UIParticle>().StartEmission();
await MoveChipToPosition(_initialPosition, playPlaceAnimation);
GetComponentInChildren<UIParticle>().StopEmission();
// _particles2DCircle.Stop();
// _particles2DStars.Stop();
...