How to keep same size relative to screen with different resolution

Hi Team,

I draw a Ellipse on screen attached to an AdvancedDynamicTexture, when I change the engine.setHardwareScalingLevel the ellipse size also changed. How to keep 2D UI with same size when scaling level changed? Thank you for your help

Hi,
There is more to it, but the basics are in this PG.

You can set adaptive scaling with an idealWidth and/or idealHeight to your GUI.
You can also use ‘window.devicePixelRatio’ on your advanced texture, like this:

advancedTexture.rootContainer.scaleX = window.devicePixelRatio/2;
advancedTexture.rootContainer.scaleY = window.devicePixelRatio/2;

The part that is not in the PG is about how to remove the blurry look resulting from this. I guess it is on engine creation
I believe there is one more with pixel perfect or something, can’t find it right now (sry) but may be someone else will reply…

2 Likes