- Home /
How can I scale the Joystick and TouchPad?
Sorry if this question has been asked before. I searched and searched but couldn't find a solid answer.
I'm a beginner at Unity. I'm currently working on a simple FPS for Android and iOS. The problem I'm having is that I can't figure out how to scale the controls so that they stay in the right place on higher or lower resolutions. When I made my main menu for the game, I used transform for the position and scaling and everything stays in the right place when changing resolutions. However, the standard touch pad and joystick controls are set up using pixel inset so the size and position get messed up on lower resolutions.
When I tried using transform for the touch pads instead of pixel inset, the controls no longer worked when testing on my phone.
I'm trying to put a joystick on the lower right side of the screen and have the entire right side of the screen used for aiming. The joystick and touch pad should scale appropriately for lower resolutions without overlapping or moving off the screen.
Any help would be greatly appreciated.
Answer by suribe · Mar 10, 2014 at 10:43 PM
You can use Screen.width and Screen.height for getting the resolution, and scale your controls accordingly. i.e., if you designed them for a 1024x600 screen but its 800x480, your height is (480/600) of the original, so you scale on Y accordingly. Of course, if the aspect ratio is different, then you have to decide what to do.