Supporting Portrait and Landscape Modes on Web

Godot Version

4.3

Question

Hello everyone, I’m having trouble with having the game I’m developing for Web support Portrait mode in case the game is played on a mobile device.

The game does indeed change orientation, but all it does is rotate the viewport, and what I need is to change the UI layout and viewport size when Godot detects a change in device rotation. I’m not able to effectively detect a change in rotation with a HTML export as you would with an Android/iOS export, and all the multiple aspect ratio advice is oriented to mobile without Web and doesn’t seem to work on a Web export.

I’d appreciate advice, sorry if I’m missing out on anything obvious.

The signal get_window().size_changed still detects the inner HTML window size so you can use that to change the screen size and the aspect.

Edit: Unfortunately while I can detect window changes, I seem to be unable to change the viewport’s size and I have a 1920x1080 screen that sits in the middle of the screen. I seem to be unable to change this size.