Window aspect ratio


As of now when we build in window mode the window doesn’t respect the aspect ratio and scales to whoever size we want.

Is there a way to lock the window to an aspect ratio?

Good question. This is more of a SwiftUI thing that once we figure out what it is, we’d have to figure out some way to expose (or you can do it yourself in the trampoline). On other iOS-like platforms there really isn’t a “window”, and so this doesn’t really come up.

This is something I’m noticing now as well. In this example that I am building, I’ve a variety of UI elements, look like the aspect ratio not locking is affecting everything. See the images below:

Curious if there is a fix available or perhaps this is something in the backlog?

Thank you!

@v_vuk @davidresolution this is the fix for now, Unity will need to do something similar within their code generation process.

Under the generated Xcode Project > Classes >

Source code:

// Initialize Geometry Preferences
UIWindowSceneGeometryPreferencesVision *preferences = [[UIWindowSceneGeometryPreferencesVision alloc] init];

// Set resizing restrictions
preferences.resizingRestrictions = UIWindowSceneResizingRestrictionsUniform;

// Request geometry update
[_window.windowScene requestGeometryUpdateWithPreferences:preferences errorHandler:^(NSError * _Nonnull error) {
    // Handle error if any
    NSLog(@"Error occurred: %@", error);

Thanks you so much for sharing your solution @dilmerval!

Anytime @davidresolution !