- Home /
Particle system not scaling in canvas with screen dimension change
Hi,
I have a canvas with a bunch of UI objects on it. They all work and they adjust and scale appropriately when I change the screen dimensions. I also have a particle system on a canvas. It is in the UI layer. In my main screen resolution it works great. When I change to iPhone size the particle system adjusts its position, but not to the right spot regardless of where I put the anchors and its scale does not change with the rest. I've tried playing with the scaling mode in the particle system, and I've scoured the internet and tried everything I can think to, but to no avail. Any thoughts?
Thank you for any help.
Have you parented the particle system object to the UI object you want to locate at?
Yes, I've tried it as its own object, and with that object parented into another UI Object. No change.
Answer by tormentoarmagedoom · May 23, 2019 at 05:01 PM
Hello.
As far as I know... The particle system gameobject scales, The problem is that the particles spawned still have the same size, so are not scaled.
Must be changed by code.
You cna do something like:
Particle size = 2*PArticleSystem.transform.localscale.x
So it will scale automatic with all scales.
Bye!
Thank you for the assistance. I must be misunderstanding something. In trying to make it work I've gotten as far as putting the code onto a script on the particle system object with:
ParticleSystem.Particle size;
void Awake ()
{
size = 2 * ParticleSystem.transform.localScale.x;
}
but from this I get an, "An object reference is required to access non-static member," error and an, "Cannot implicitly convert type float' to
UnityEngine.ParticleSystem.Particle'," error.
with:
ParticleSystem.Particle size;
void Awake ()
{
size = 2 * transform.localScale.x;
}
I lose the first error, but still get the, "Cannot implicitly convert type float' to
UnityEngine.ParticleSystem.Particle'," error.
$$anonymous$$an i told you the idea not the code... go find how to acess the size of the particles, doa goood reference to the particle, and not multiply by 2... was only an example..