3
\$\begingroup\$

I have a Panel with an AspectRatioFitter on it.

In there, I have a vertical layout group, with three buttons, Standard Mode, Speed Mode, Chaos Mode.

I have the Layout Group's anchors set to keep its size relative to the parent Panel.

The problem is that the text doesn't resize when I change the screen resolution. You can see it's cut off to say "Standard M" in the bottom image.

enter image description here

enter image description here

But if I say "Best Fit", the texts aren't the same size, because the boxes are big enough to allow the shorter text to be bigger. The only way I've been able to fix this is to adjust the sizes and anchors of the text boxes by hand. Is there an automatic way to do this?

enter image description here

\$\endgroup\$
  • 1
    \$\begingroup\$ also looking for the answer to this conundrum \$\endgroup\$ – Joe Aug 30 '15 at 19:11
2
\$\begingroup\$

Ok, I think I have it. Set the Canvas to use "Expand". No messing around with text box sizes or anchors, it just seems to work.

To be absolutely clear, I am still using the Aspect Ratio Fitter to force my Panel to maintain its aspect ratio, and it's set to Fit In Parent, which is the Canvas, and that is always the size of the screen.

enter image description here

Results:

enter image description here enter image description here

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

You are trying to fit the same layout for horizontal and the vertical orientation. I am afraid it won't be easy to make it happen by tweaking the layout properties. It needs to be done manually through code.

  1. Scale the button as a percentage of Vertical side (ButtonHeight=
    Screen_vertical*0.2)
  2. Scale button width according to the newly calculated height and button's aspect ratio
  3. Position it in the middle (Screen_Horizontal/2)
  4. Anchor side buttons at (ScreenWidth +- offset)

You need to check if the layout works for the following aspect ratios (widest to narrowest), they will cover both android and iOS devices:-

  • 5:4
  • 4:3
  • 3:2
  • 16:10
  • 16:9
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ The game will only ship portrait. But I'm using the Aspect Ratio Fitter to "black bar" the layout and use a fixed aspect rectangle for the UI. I am testing by switching between landscape and portrait to make sure it's scaling things the way I expect. \$\endgroup\$ – Almo Aug 31 '15 at 13:27

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.