Window width not screen width?

When the browser is getting resized, smaller rectangle than the screen size unlike in full-screen mode, how we can get the resized windown width & height?

screen.width and screen.height are intact when the browser window is resized.

Hi @lenvanthis,

If you are talking about the UI screen component width/height, those are just reference values. Not the actual window size.

You can get the PlayCanvas canvas size using this properties:

const graphicsDevice = this.app.graphicsDevice;

const width = graphicsDevice.width;
const height = graphicsDevice.height;

Thanks, Leonidas,

But when the browser resized by a user, can we have the browser size? I have never needed the value but now since I use css position for my UI. I need to know the actual browser window size.

You can subscribe to this event whenever the canvas is resized:

this.app.graphicsDevice.on('resizecanvas', function(){

   const newWidth = this.app.graphicsDevice.width;
}, this);

https://developer.playcanvas.com/api/pc.GraphicsDevice.html#event:resizecanvas