mob-sakai / ParticleEffectForUGUI

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

How to resize particles to fit UI container #332

Open jgib332 opened 13 hours ago

jgib332 commented 13 hours ago

Unity Version: 2022.3.20f1 ParticleEffectForUGUI Version: 4.9.1

I am unsure if I'm using the wrong UI Particle settings or if Auto Scaling Mode is not working correctly.

  1. Create a Canvas
  2. Create an empty container object under the Canvas, set anchor to stretch, set Left, Right, Top and Bottom to 0.
  3. Create a Particle System under the container object (Effects > Particle System). NOTE I am NOT using (UI > Particle System).
  4. Set the anchor of the Particle System to stretch, set Left, Right, Top and Bottom to 0.
  5. Set the Scaling Mode of the Particle System to "Hierarchy".
  6. Select the container object, add a UI Particle component. Set the Auto Scaling Mode to "UI Particle", set the UI Particle component Scale to 1.
  7. Select the Particle System and set the emitter shape to "Edge", edit the emitter to span the width of the canvas, increase the Start Size so particles are visible.
  8. Open the Simulation tab and change the device to something with a different aspect ratio.

You will see that the particles do not stretch to fit the width of the canvas. If the system is created on iphone ratio it will be too small after switching tp an ipad ratio. If the system is created on an ipad ratio it will be too big after switching to an iphone ratio.

How can I get my particles to resize correctly under the Canvas or under a container that changes size under different aspect ratios?

jgib332 commented 13 hours ago

UIParticleTest.zip

SampleScene.unity includes the setup described above in the issue.

SampleScene2.unity includes a more complicated setup with a screen space canvas and an aspect ratio fitter with the same issue.