# Make virtual joystick preserve aspect ratio Android in Unity

When I start my game on Android my virtual joysticks stops being round.

Here you can see it:

Here is the project on PC at the same time:

Here are my UI settings for the Joystick:

Please, help me to find a way to preserve the roundness on the Android phone. It feels to me that the solution to the problem is straightforward, but my lack of knowledge prevent me from getting it. What I tried to do is to tweak settings in Editor, in particular I checked preserve ratio on all elements images as you can see on screenshots, but it did not help. I think it did not due to the fact that there is a code executed every time which is this:

Screen.orientation = ScreenOrientation.LandscapeLeft;


And I think that it changes ratio even though I preserved it in Editor. So, help me out of the problem, please.

• Why is Screen.orientation = ScreenOrientation.LandscapeLeft; executed every time? If you don't know if it's causing the bug, disable it and check if it solves the problem. – Jacob Jun 18 '17 at 17:46
• Your problem has nothing to do with your joystick. EVERYTHING in your scene is getting squashed. s12.postimg.org/sofff4ycd/squash.png – Draco18s no longer trusts SE Jun 18 '17 at 17:59
• issuetracker.unity3d.com/issues/… – Jacob Jun 18 '17 at 18:37
• @Spectre, I do not understand the solution provided by you. Sorry. – Yaroslav Jun 18 '17 at 19:47
• Why do you use the Screen.orientation? – Jacob Jun 18 '17 at 19:52

If you want to specify game orientation, go to File -> Build Settings -> Player Settings and there open a tab Resolution and Presentation.
And delete that line: ScreenOrientation.something from your code. I'm 99% sure that it causes all the stretching.
• Export your project and upload it somewhere so I can download it. Go to Assets -> Export Package and upload the .unityPackage to some dropbox so I can download it. – Jacob Jun 19 '17 at 7:35