Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by POLYGAMe · Oct 08, 2012 at 03:54 AM · iosiphoneguitextureipad

How to change button sizes depending on iOS device?

Hi everyone,

I am using code similar to the following to change button scale and position depending on whether the user has an iPhone or iPad... but it doesn't work. What am I doing wrong?!?!?!

  function Start () 
     {
         if (iPhoneGeneration.iPhone3GS ||
             iPhoneGeneration.iPhone4 ||
             iPhoneGeneration.iPhone4S (...and so on)
             )
         {
             // Pos x, pos y, height, width. Using screen height for both assures button doesn't deform
             GasButton.pixelInset = Rect (-64, -64, (Screen.height / 4), (Screen.height / 4));
             GasButton.transform.position.x = 0.93;
             GasButton.transform.position.y = 0.15;
             
             
         }
         else if (iPhoneGeneration.iPad1Gen ||
                 iPhoneGeneration.iPad2Gen ||
                 iPhoneGeneration.iPad3Gen ||
                 iPhoneGeneration.iPadUnknown)
         {
             // Pos x, pos y, height, width. Using screen height for both assures button doesn't deform
             GasButton.pixelInset = Rect (0, 0, (Screen.height / 8), (Screen.height / 8));
             GasButton.transform.position.x = 0.82;
             GasButton.transform.position.y = 0.4;
             
         }
     }

I should add, for the Android version of the game, the user can select whether they have a phone or a tablet, using the same code above, basically, and it works fine. It's the iPhoneGeneration enumeration that doesn't seem to be working for me...

Comment
Add comment · Show 7
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image fafase · Oct 08, 2012 at 08:43 AM 0
Share

Euh, "never use "else if" in program$$anonymous$$g." is a personal point of view that I think might not be shared by most programmers.

$$anonymous$$arl, what is not working?

avatar image POLYGAMe · Oct 08, 2012 at 08:52 AM 0
Share

What's wrong with using if else statements? I don't see why that would break the code... and I love globals! I'm lazy (and nobody else sees my code)! Hahaha.

I'll give yours a go, but I am at a loss as to why my code isn't working... do I need to run it right upon loading of the app? As it stands, that script is called just before the buttons are placed on the screen.

avatar image POLYGAMe · Oct 08, 2012 at 08:56 AM 0
Share

*else if :P

avatar image POLYGAMe · Oct 08, 2012 at 09:17 AM 0
Share

I'm not in the program$$anonymous$$g field, I do it out of necessity. Hard to find coders to work for free! Still... I have a game out and none of the players know what's in the code, so as long as it works I use it :P I won't use globals when coding in C++ generally, but I'm not quite sure I could avoid using them in Unity...

Still... the original issue stands... for some reason, this code is not working...

avatar image Fattie · Oct 08, 2012 at 09:44 AM 1
Share

LOL classic dude! nice spot. good luck ...

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by kumarc123 · Apr 07, 2014 at 01:47 PM

Hello,

Check out this link. It is actually in Chinese. Google will help in translating it into English. This will give you details about why you can't solve your problem and also the possible solution to it. The site also has some useful tutorials about Unity. Hope this may help...

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Ampersand in application name 4 Answers

Pinch vs. Rotate gestures: can they be made size/resolution-independent? 2 Answers

Are soft shadows supported on iOS ? 2 Answers

need help launching game to app store 1 Answer

iphone ios version and sdk version 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges