Problem with HUD resizing


I have an issue with the HUD resizing in the editor preview mode. The game is designed for portrait view on mobile phone, and so is the HUD. When I press play in the editor, the editor plays the game in a viewport that is not the same aspect ratio as I defined in the camera. For most of the content this is not a big deal, I just get empty areas on the sides, but the HUD is stretched out over the whole viewport.
I specifically notice this when I use ‘Draw Debug String’. The x-location of the string that is drawn does not match the x-location of the actor it’s attached to. IF I start resizing the viewport of the editor so it matches the 4 by 3 portrait view, the debug text is aligned with actor again.
What I would like to know: can I tell the engine/editor to NOT stretch out the HUD over the whole editor viewport, but let it be centered and keep the aspect ratio I set in the camera and in the canvas panel of the HUD?
I hope I made my problem clear and someone knows a solution, or else I will include some screenshots.


I am not quite sure if that is what you are looking for, but in the designer tab when you press on one of the UI elements there should be a white start kinda thing in the top left corner. When unhover over it some of these things should turn green. Pull the whole thing (press of middle part of star) and drag it to 50/50. Do this for all elements and test again. But this might not be what you were looking for not sure

can you post a screenshot of what is happening

This is the hud, with a canvas set to portrait:

This is the camera, also set to portrait:
This is the screen as it should be (if I resize the editor viewport to portrait):

This is the normal view when I play the game in the editor, where the HUD is stretched out, which also causes the ‘draw debug string’ to be in the wrong x-position:

(Note that I removed some parts of the screen to sort of hide some things of the game, sorry my co-worker insisted :stuck_out_tongue: )

I hope this makes clear what the problem is. First I thought the stretching of the HUD was a ‘feature’, but now that I know that the debug strings are drawn in the wrong place, I believe this should be seen as a bug. Any ideas on how to fix this?

have you tried it using the mobile previewer? (click the down arrow beside play button and click mobile)

Yes that seems to work. A downside is that it seems to restart the whole game, which takes a long time, instead of instantly playing as I can do in the editor. Also you can’t ‘eject’ yourself in mobile preview. So it’s not really a lasting solution for me at the moment.

Yeah I know what you mean it is awkward but at least you know the hud works :smiley: