- Home /
GUI button fit on both iPhone and iPad
Hi there, I have made a game, which has a level scene, where I have a background with a road on. I would like my level icons to be on that road, but the problem is that all the GUI buttons, that I have programmed to be on the road, fits in the editor and on the iPhone, but it doesnt fit on the iPad. To place the icons, i am doing this. (example)
if(GUI.Button(Rect(Screen.width/2-100,Screen.height/2-100,100,100);"")){ }
Anyone who knows a way to solve this? Or is there a way, to make a "map" that will place the buttons, in the right places?
Answer by Dragon-Of-War · Nov 12, 2014 at 04:09 PM
If the problem is the bad positioning, then i have a solution.
Lets start with the width
If this gui is more to the left make:
Screen.width/Screen.width+"Somenumbervalue"
If its more the the right then make:
Screen.width-"SomeNumberValue"
Now the height
If the gui is more heigher then do:
Screen.Height/Screen.Height+"SomeNumberValue"
if the gui is more low then do
Screen.height-"SomeNumberValue"
If your satisfied with your positioning process, ignore above
If your problem is with the bad scaling, you can make the "Screen.width/2-100,Screen.height/2-100" process in the scaling part of the script. Example :
if(GUI.Button(Rect(Screen.width/2-100,Screen.height/2-100,Screen.width/2 -100,Screen.height/2-100);"")){ }
Everything might work properly if im right
I appreciate your help, but it does not seem to work. The main problem is, that the guis on the iphone are placed right and as it is in the editor, but when it is downloaded and played on the iPad, the buttons are places like on the iPhone, but because of that, the buttons are placed far off the "road" on the background, because the background scales to iPad size.
Answer by BlastOffProductions · Aug 08, 2016 at 07:14 PM
The only solution I can find is to make two versions. One for iPhone and one for iPad. Sorry I can't find a better solution, i'm trying to figure out a way around this too.
Answer by BlastOffProductions · Aug 08, 2016 at 07:14 PM
Ok, try these Canvas settings:
Your answer
Follow this Question
Related Questions
apple rejected app due to iphone & iPad resolution mismatch 1 Answer
Detecting an iPhone app running on an iPad 1 Answer
Detect device and adjust screen 2 Answers
Specify iphone project 1 Answer
Setting resolutions for iPad and iPhone 0 Answers