Changing GUI placement when changing from landscape view to portrait

Hey,
Is it possible to give the GUI buttons new placement ( not according to screen resolution ). That when the user changes to portrait the GUI buttons get new placement?

Pretty simple: Just use variables to fill in the positions, then you just need to change the variable to your new position, done! :slight_smile:

Could you give me an example please?

Lets say here is my first button, and this position is in landscape left

GUI.Button(Rect(512,0, 512, 768)

When I go to portrait, I want the same button to get a new position like

GUI.Button(Rect(20,20, 512, 768)

as said just replacce your values with an variable:

var offsetX : int = 512;
var offsetY : int = 0;

GUI.Button(Rect(offsetX,offsetY, 512, 768)

then all you need to do is, when you want to change the position of your button, just change the variable:

offsetX = 20;
offsetY = 20;

btw I’m using c# not javascript, so there might be some syntax errors you need to fix :stuck_out_tongue:

P.S. the code-tag consumes the “o” from offsetX, dunno why, so it’s no writing mistake ^^

From Documentation

if( Screen.orientation == ScreenOrientation.LandscapeLeft)
//Do Whatever you want

Help please

I am having big problem adding auto rotation to my iPad application, my GUI buttons are coded for landscape mode and when turning to portrait, they just disappear… I am aware that its possible to place GUI buttons according to screen resolution, but it doesnt help me…

Here is my buttons and their placement
Button 1: X: 40, Y: 675
Button 2: X: 940, Y: 675
Button 3: X: 531, Y: 708

Thats landscape mode, and when changed to portrait I want my buttons to get this placement
Button 1: X:50, Y:880
Button 2: X: 676, Y: 880
Button 3: X: 402, Y: 905

Can anyone please help me out? I really need your help with that :slight_smile:

Think a bit before posting, you have all answers in here…

ahaykal posted the if statement, when the screen turns, and you can use my answer to change button positions…

solved!

Thanks for your help guys =)