It seems that whenever I try to code any GUI stuff that should theoretically work, Unity doesn't like it. In the Script Reference, they tell you how to draw Controls, but they only use integer values. However, I'd like the buttons inside to change position relative to the Screen Resolution, but it doesn't really work. Any ideas?
What I do is use co-ordinates based on a percentage of the screen rather than absolute position. So I've this utility function to create me a Rect:
Anytime I want to place a GUI item I then do something like:
This for example will create an area that uses most of the screen at is 10% (0.1) in on the left and is 80% (0.8) of the screen width.
Thats all well and good but then for things like buttons its no good as it depends on the apsect ratio. ie the button will be a strange shape the screen is landscape vs portrait.
So for buttons / labels I do something a bit different. I have a function that basically uses the a percentage of the largest of either width or height.
I can use that with buttons like this:
As long as the aspect ratio generally stays the same the system works well. ie 3:2 or 4:3 in either orientation are close enough. Screens wont be identical between a 3:2 and 4:3 device buts its close enough.
I have an App that displays things correctly on retina display iPad and iPhone as well as non-retina display iPhone and iPad in either landscape or portrait orientation. Looks good on the computer screen as well.