0
\$\begingroup\$

After completing my game and sending it to a bunch of friends with different devices, they complained about how some game buttons were too small. (I have developped a touchscreen game but after finishing and having issues with the touch detection I just decided I'd place buttons for controls on the screen. ) I obviously put all the button in a canvas, so it should normally scale with the screen and keep its anchor point, but the problem apparently is that it DID keep the anchor point, but it didn't scale, so even though the buttons looked pretty huge on my small sized game screen, and looked decent in an 480 x 800 emulator, it looked very mini sized in a 720x1280 phone. Any help on how I can make a button scale to the screen? Thanks!

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

You can manually scale it by setting the size to be a percentage of the screen width/height. Make a variable(if you want) that is a value from 0.0 to 1.0 and multiply it by Screen.height(or .width). That is your new width/height. You should make the position relative also. Nevermind that part, you said the anchor works.

\$\endgroup\$
  • \$\begingroup\$ If the OP is using Unity's UI components, there is absolutely no need to do this with code. \$\endgroup\$ – livingtech May 18 '17 at 19:17
3
\$\begingroup\$

You can preview how your game looks with different sizes of screen and aspect ratios in the Game tab. (The one that shows when you hit "Play" to play your game in the Unity editor.) There is a dropdown under that tab to switch resolutions. I'll attach a screenshot.resolution dropdown

Note that what options are in the dropdown will change based on your selected platform under build settings.

\$\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.