Centred gui buttons ios7 and ios8

when on an IOS7 device and IOS8 devices the code below behaves differently

private float guiRatio;

private float sWidth;

privateVector3 GUIsF;

voidAwake() {

sWidth = Screen.width;
guiRatio = sWidth/2048;
GUIsF = new Vector3(guiRatio, guiRatio, 1);
}

And in OnGui …

GUI.matrix = Matrix4x4.TRS(newVector3(GUIsF.x,GUIsF.y,0),Quaternion.identity,GUIsF);
GUI.Button (newRect ((Screen.width/2)-256, (Screen.height/2)-256, 512, 512), overlayButton, styleLost);

So using this code on IOS8 the overlay button always appears centred in either orientation but on IOS7 the overlay appears in the top left?

What versions of Unity and Xcode are you using?

Hi, I’m using Unity 4.6.1f1 and Xcode 6.1.1

I think I have found the answer! 4.6 includes a new gui creation setup…and that is much better :slight_smile:

1 Like