I'm trying to set up a GUI menu in Unity that will work for all devices. So I started it in setting it up for one resolution that is: 1024 * 600.
It looks ok on that, so I tried adding a scaler to make it look ok on all the rest to.
Example of my code for getting scaler:
float originalWidth = 1024;
float originalHeight = 600;
Vector3 scale;
scale.x = Screen.width/originalWidth;
scale.y = Screen.height/originalHeight;
scale.z = 1;
Then I resize every element with that scale like that:
rect = new Rect(width/2 - 65 * scale.x, height/2 - 50 * scale.y, 130 * scale.x, 65 * scale.y);
But it just doesn't look the same. I also tried like that:
rect = new Rect((width/2-65) * scale.x, (height/2-50) * scale.y, 130 * scale.x, 65 * scale.y);
but it just looked even more wrong.
So to be clear I would like my element to be in the middle of screen with some offset and look the same on all devices.
The biggest problem is when 2 elements needs to be aligned to each other perfectly.