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

Particles only scale correctly under nested canvas? #313

Closed jgib332 closed 5 months ago

jgib332 commented 5 months ago

Unity version: 2022.3.20f1 UI Particles version: 4.6.7

My Particle System only looks correctly scaled under a nested Canvas component.

I was attempting to create a setup where the Rect Transform of the particle parent object can be scaled to (1,1,1), and the UI Particle component scale can be set to 1.

Setting the UI Particle component Auto Scaling to "UI Particle" and the Scale to 1 will display my particles at correct scale, but only when a nested Canvas component is added to my particle parent, or if the particle parent exists as a child of an object with a nested Canvas component attached.

Steps to reproduce:

  1. Create a Canvas with Screen Space - Camera and add an orthographic Camera.
  2. Create an Empty gameobject under the Canvas to act as the parent.
  3. Create a Effects > Particle System as a child of the Empty gameobject parent.
  4. Add a UI Particle component on the parent, set the Auto Scaling to "UI Particle", and Scale to 1. You will see the particles are not at the correct scale (they are very small).
  5. Create a Canvas component on the parent object. You will see the particles at the correct scale.

Question: Is this a bug or intended?

Setting Auto Scaling to "Transform" will set my Rect Transform to scale of (253.2, 253.2, 253.2) but the particles still do not render at correct scale without the nested Canvas component.

Setting Auto Scaling to "None" will still not display particles at correct scale, even if I set the UI Particle component Scale to 253.2.

mob-sakai commented 5 months ago

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?

repos

jgib332 commented 5 months ago

UIParticleTest.zip

mob-sakai commented 5 months ago

Thanks! I found three bugs by your project.

Bug 1: UIParticle is scaled incorrectly with nested canvases

Setting Auto Scaling to "Transform" will set my Rect Transform to a scale of (253.2, 253.2, 253.2), but the particles still do not render at the correct scale without the nested Canvas component.

This behavior is as intended. AutoScalingMode.UIParticle or AutoScalingMode.Transform scales to ensure a consistent display regardless of screen size changes. However, with nested canvases, a bug was causing it to be disabled.

Bug 2: UIParticle.transform.localScale does not scale UIParticle

Bug 3: UIParticle is scaled by canvas size even when AutoScalingMode.None and ScalingMode.Local

mob-sakai commented 5 months ago

I will fix them soon.

github-actions[bot] commented 5 months ago

:tada: This issue has been resolved in version 4.7.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

github-actions[bot] commented 5 months ago

:tada: This issue has been resolved in version 5.0.0-preview.2 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: