- Home /
Unable to make my UI independent of screen resolution
Hello Friends,
I am working in a project for mobile app and I am stuck at a point. I have to deploy that particular app in all possible mobile platform.
I am trying to fix the canvas scalar component but it does not help. The output in mobile and tab for android is different (same in iOS too). Also the UI elements changes the position with the device which is strictly not accepted. I am using pretty much the same UI elements like panels, images, buttons etc. I have gone through many tutorials and unity blogs but could not find things helpful according to my need.
Please help me and suggest some better way to solve the problem. I am posting this after my research and this is a genuine question. It will be a great help tome.
Thanks,
so have you changed the canvas scalar in the inspector to the Scale With Screen Size if so & didn't help then you have to do some coding to position or scale UI elements according to the screen size so it will be the same for all screen sizes example :
public Transform button1;
void Start()
{
buttton1.position = new Vector2(0,0);//lower left corner of the screen
}
Yes I have changed the canvas to Scale With Screen Size. I don't understand the solution you gave me is very limited. What about panels and Background Image to fill the screen Completely. What shall i use then? And the image, panel button shall change size according to the device. I don't thing your solution is dynamic. Please correct me if I am wrong.
You really haven't provided much information, so it's kind of hard to help you. How have you anchored your elements? $$anonymous$$obile devices have different sized aspect ratios, so if you want to fill the screen you have to either let them reposition or let them stretch (or both) - these are controlled by the RectTransform component. Please post some screenshots of what you are seeing, and what you are trying to achieve, and also what settings you are currently using on your UI elements.
Answer by W4rf4c3 · Mar 15, 2016 at 08:49 PM
Are you using the anchors from the UI Gameobjects ? This will help to snap them in the same position whatever the resolution is.
Answer by laharl219 · Mar 15, 2016 at 05:54 PM
Are you using anchors in your UI elements? It's really usefull (link about anchors http://docs.unity3d.com/Manual/HOWTO-UIMultiResolution.html)
You can also adjust resolutions via script. This might help you: http://answers.unity3d.com/questions/618058/mobile-device-screen-sizes.html
hope i could help you.
Answer by SaurabhStudio · Mar 15, 2016 at 06:30 PM
Hello @sovan.k1
as @laharl219 says, you have to place anchor properly and manually.
This video may help you.
Your answer

Follow this Question
Related Questions
Find UI Image position in Screen Space 1 Answer
How to track a world object in a Screen Space - Camera Canvas 1 Answer
Efficiency & More: OnGUI() versus RectTransforms on a Canvas? 2 Answers
Can't get proper local point of rectangle for mouse click 2 Answers
My canvas recttransform.rect.height don't change properly 1 Answer