0
\$\begingroup\$

I have two UI Buttons with image sprites in Panel (inside canvas). I have set their sizes to 40 in the inspector. If I run game in maximize mode, buttons retain constant assigned size of the inspector, instead of adjusting themselves with screen size. I have already added Canvas Scalar component with value Scale with Screen Size. Text fonts are able to adjust with screen size present in same canvas, but button with image does not.

Any guide on this? Thanks.

\$\endgroup\$
  • \$\begingroup\$ Think of it this way: If your buttons are a bitmap graphic, then scaling them will result in blurry or pixelated buttons, fonts scale because they are vectors. An option can be to use several bitmap sizes for different screen sizes, but I don't know how to do that on Unity. Leaving this here as an idea for someone that knows. \$\endgroup\$ – rlam12 Sep 11 '16 at 22:33
  • \$\begingroup\$ @rlam12 Thanks for the idea. I will look into it. \$\endgroup\$ – NightFury Sep 11 '16 at 22:41
0
\$\begingroup\$

If I understand your question correctly, you are using the new (Unity 4.6 and up) UI system. Part of that system includes a set of triangularly shaped handles (when viewed using the rectangular toolbar...tool.

enter image description here

As an example, that tool is selected in the above image and the selected button has the triangular handles all set to the button's upper left corner. These are the UI object's anchors and are used to dictate how the UI object scales when the screen resolution changes. In the above case, the button would not scale at all and would remain anchored to the upper left corner of the canvas (as that's where the anchors are).

Alternatively, you can modify the anchor values directly in the inspector using the >Anchors property or the Rect Transform's quick anchor align tool (in the above image it shows "top left" with a square with the top and left sides in red).

This is effectively what you want to do, although you will need to figure out what specific values your UI needs.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.