Mike
Mike

Reputation: 133

Build android app as a unity stand-alone (for use on a PC) while maintaining correct aspect ratio

I am attempting to build my Unity Android app (1080 x 1920 res) so that it can also run on PC (1920 x 1050 res). To do this, I need to fit vertically to the computer screen while maintaining the correct aspect ratio. I'm nearly there.

I'm using the following code to scale my app resolution down to fit the vertical 1080 of the monitor (android vertical 1920 down to monitor vertical 1080):

    #if UNITY_STANDALONE
        Screen.SetResolution(608, 1080, false);
        Screen.fullScreen = false;
    #endif
    popUpConfirmRemove.enabled = false;

This works for the most part (after I manually set the pivots of each gameObject corners of the that transform). However, I have a scroll rect UI element, that doesn't scale correctly! That is because there is a vertical layout group on the scroll content that automatically adjusts the pivots.

When I build scale my app to fit on PC, the scroll content doesn't adjust properly.

I would love some help with this! How do I scale my Scroll Rect - Vertical layout group contents? Thank you

Upvotes: 2

Views: 125

Answers (2)

Huacanacha
Huacanacha

Reputation: 1161

Try setting the CanvasScaler to "Scale With Screen Size" and set your reference resolution to match your Android app (1080 x 1920) so all UI layout calculations are done to that target resolution. If the aspect ratio is the same it shouldn't matter what you set the Screen Match settings too.

Upvotes: 1

Himzy 101
Himzy 101

Reputation: 11

Have you stretched anchors to full? Use cntrl key on anchor selection and try the last option.

Upvotes: 1

Related Questions