I want to place 4 buttons on top left, top right, bottom left, bottom right corners.
And the button size is 16 x 16. How should I set their x,y coordinates properly?
var redLightRec: Rect;
var blueLightRec: Rect;
var greenLightRec: Rect;
var purpleLightRec: Rect;
function OnGUI() {
GUI.Button(redLightRec, "Red");
GUI.Button(blueLightRec, "Blue");
GUI.Button(greenLightRec, "Green");
GUI.Button(purpleLightRec, "Purple");
}
iPhone resolution is 480 x 320, in landscape mode.
Gui buttons use regular old “pixel” coordinates, so (0, 0) is the top left hand corner, while (480, 320) would be the bottom right corner.
If you know the button size, you can do a little math to determine their placement, or you can simply tweak the X and Y value of each rectangle while your game is running.