2
\$\begingroup\$

My UI appears extremely small when i build and launch my game on my android device. Im working with unity 4.6. I've tried changing the UI scale mode of my canvas to all 3 types. Scale with screen size option and constant physical size option makes it too big. Constant pixel size makes it too small. With constant pixel size this is what it looks like on my mobile:

enter image description here

I could increase the scale factor but then it looks like this on PC. Also, I don't think it would look right on a tablet then.

enter image description here

\$\endgroup\$
2
  • \$\begingroup\$ I'd say that you need to write some sort of script which takes the DPI of the current device into account. I think there is already a canvas scaler component for this built-in Untiy (however: for my needs it was always to inflexible). \$\endgroup\$
    – M156
    Commented May 3, 2016 at 9:32
  • \$\begingroup\$ what reference resolution have you provided to the canvas scaler. Have you tried setting match width or height to 0.5 ? \$\endgroup\$
    – Uri Popov
    Commented Sep 8, 2016 at 11:30

3 Answers 3

2
\$\begingroup\$

Make sure you set your anchor points to the corners of your graphics if you are using Scale with Screen Size. I have often run into problems when using the presets for middle, corner, etc when building to an actual device and setting the anchors directly on the corners usually fixes the problem.

enter image description here

\$\endgroup\$
1
\$\begingroup\$

You are 2 steps away from solution.

1- Select Canvas and change UI Scale Mode in Canvas Scaler to Scale With Screen Size in inspector.

Canvas

2- Set screen size from Free Aspect to any other size in Game tab.

Size

Now adjust your UI, it will remain same as in Unity Editor.

\$\endgroup\$
1
  • \$\begingroup\$ Tried this it didn't work. \$\endgroup\$
    – AeonSage
    Commented Feb 7, 2016 at 15:19
1
\$\begingroup\$

I know this thread is pretty old, but I have a solution. When it comes to scale by screen size, the trick is to use a reference resolution that will scale up and down in a way that will fit AND set the match so it knows how to scale. I have been using .5 for that. Here are a couple examples of common sizes that you can use to scale up and down in Unity. I like to use these sizes because they have a scale up and down that is in the common range. When using an image or sprite that only works in one aspect, you can check the preserve aspect box to make sure that image looks right every time. If you're just coloring the button, you don't need to use this option.

  • 640 x 960 (SD)
  • 1280 × 720 (HD)

Another thing to consider is how the objects will remain in the frame when changing from landscape to portrait, as well. By default, Unity sets the anchor points to the center of the canvas. If you set them to the closest corner instead you will notice that when changing the landscape it will also maintain the proximity to the anchor point that was set.

enter image description here[ Credit Unity Docs]

Doing these things together should help with most resolutions.

Another side note, when objects are set to be children of objects that are already children of the Canvas, the anchor points are then set back to center of the object it's a child of. This can also cause undesired results.

Here are samples of a project I put together for this purpose:

16:9

4k

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .