I was just wondering if there was any way to constrain a UMG widget to 16:9 in game, as it doesn’t seem to follow the player’s camera’s aspect constraint?
Thanks
I was just wondering if there was any way to constrain a UMG widget to 16:9 in game, as it doesn’t seem to follow the player’s camera’s aspect constraint?
Thanks
Can you post an image showing what you’re trying to achieve? How would the constraining work?
Well, when you constrain a normal camera’s aspect ratio, in editor black bars appear over and under (I constrain it to 16:9)
However, there is no such setting for UMG, so if I’m playing my game, with the black bars because its constrained, and I create a UMG widget and add it to viewport, it takes up the whole viewport, and not just the constrained part.
Just checking, yeah we don’t lock the UI to any constraints set on the camera, probably should.
The offhand way I think you could fake it would be to make your root widget on any fullscreen UI you have a SizeBox set to the 16:9 resolution you want to be the nominal scale 1 resolution for your games UI. Then place that inside a ScaleBox set to scale to fit, and disable the DPI Scaling curve, otherwise you’d get double scaling.
Alternatively, you’d need to manually determine how big the canvas should be after placing it in the viewport, and adjust it’s size and position to match the black bars.
Ok, thank you for answering
Are there any plans to change it to fit in the camera automatically?
Are you guys ever going to constrain UMG to the camera?
Seriously, this is a big problem. We need user interface elements to constrain to the camera’s aspect ratio.
Alternatively, you’d need to manually determine how big the canvas should be after placing it in the viewport, and adjust it’s size and position to match the black bars.
Could you provide a screenshot of blueprints showing how this is done?
the pesudo code of the function could be like this:
float aspect = ScreenSize.y / ScreenSize.x;
if (aspect > FixedAspect)
return ScreenSize.x / FixedWidth;
else
return ScreenSize.y / FixedHeight
And when Editing UMG, use FixedWidth and FixedHeight as your design screen size
widget root - scale box (scale to fit) - overlay (align center) - border - everything else.
I can’t believe it doesn’t lock UI to camera aspect ratio, this is a huge design flaw!
Sorry to bump this thread but has anyone figure this out? Losing my mind trying to solve this.
Jeez are we really still waiting for this feature? It’s been 8 years since this problem was brought up and we still don’t have a proper locking to aspect ratio option
This works good enough for my purpose. If allowing any-sized windowed mode, then I did find a few odd sizes that results in the scene camera extending slightly past the UI’s border. Otherwise a great solution and probably good enough for most.
There may be 2 way to try to do this(i will try later)
1:Using a fake resolution when you choose to a different aspect ratio resolution, it also uses the local viewport resolution, so the UMG will be a right aspect ratio, they will not be stretching. You have to set the target aspect ratio to camera, so the game viewport will cut unnecessary game graphics, but the problem is your mouse still can move to the outside and you have to set a mask to cover outside game graphics,also you have to reset all UI position or create a empty ui to fill the outside space,that`s low efficiency…
2:Try to Change the Windows System Resolution and aspect ratio both, it seems to use c++ to do this, and then change game resolution too,it may work prefact and no stretching, it just like to set the windows screen to another aspect ratio and the graphics will not to fill the display, and when you exit game, restore the screen resolution and aspect ratio.
i think the second way is the simple way to do this even the player will get black screen for a few seconds to change the Windows System Resolution, but it seems so many games do that…
Just ran into this myself and fixed it just by nesting the content in the right configuration of widgets. It took a minute to figure out the exact combination of settings so I figured I could share some screenshots to help
Scale box: set Stretch to Scale to Fit and Stretch Direction to Both
Size box: set horizontal and vertical alignment to “fit”, and set Mix/Max Aspect Ratio to the intended value
Content (this could also be an Overlay to nest other children, I’m just using an image): set horizontal and vertical alignment to “fit”