Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

iphone generation

Discussion in 'iOS and tvOS' started by VIC20, Oct 24, 2009.

  1. VIC20

    VIC20

    Joined:
    Jan 19, 2008
    Posts:
    2,687
    i am REALLY to stupid to understand the manual.

    Can someone please explain with some lines of code how to find out on which type of device the script runs?
     
  2. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    Try this:
    Code (csharp):
    1.  
    2. if( iPhoneSettings.generation == iPhoneGeneration.iPhone )
    3. {
    4.     //Its a first generation iPhone
    5. }
    6. else if( iPhoneSettings.generation == iPhoneGeneration.iPhone3G )
    7. {
    8.     //Its a second generation iPhone
    9. }
    10. else if( iPhoneSettings.generation == iPhoneGeneration.iPhone3GS )
    11. {
    12.     //Its a third generation iPhone
    13. }
    14. else if( iPhoneSettings.generation == iPhoneGeneration.iPodTouch1Gen )
    15. {
    16.     //Its an iPod Touch, first generation
    17. }
    18. else if( iPhoneSettings.generation == iPhoneGeneration.iPodTouch2Gen )
    19. {
    20.     //Its an iPod Touch, second generation
    21. }
    22. else if( iPhoneSettings.generation == iPhoneGeneration.iPodTouch3Gen )
    23. {
    24.     //Its an iPod Touch, third generation
    25. }
    26. else
    27. {
    28.     //Unknown device or are you in the editor?
    29. }
    30.  
    Hope it helps...
     
  3. VIC20

    VIC20

    Joined:
    Jan 19, 2008
    Posts:
    2,687
    thank you! worked fine.
     
  4. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    Glad it helps. :p
    Cheers.
     
  5. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    how do you tell the difference between touch 3rd gen 8gb (actually second gen. hardware) and 32gb (3rd gen. hardware) ?
    is there a get total device memory check or something ? or a get device name ?
     
    Last edited: May 15, 2011
  6. Tony_Luminaire

    Tony_Luminaire

    Joined:
    Jun 21, 2011
    Posts:
    10
    When getting the iPhoneSettings.generation, Unity doesn't check for the firmware, it's checking the hardware. This means even if you're running 3.0 on a 2nd gen device, Unity wil tell you that it's a 2nd gen device.

    I don't believe there is a way to get the different memory capacity types though.
     
  7. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    You don't need to get the disk space etc for that.
    The 8GB itouch 2nd gen that was sold along the iTouch 3GS is correctly recognized as being a 2nd generation itouch, it does not "stealth" itself as a 3GS device, no worries there.

    and if you wanted to check it you would never use disk space. instead you would ask it if it supports openGL ES 2.0. YES -> 3GS or newer, NO -> first or second gen :)
     
  8. kennyomar

    kennyomar

    Joined:
    Dec 31, 2010
    Posts:
    3
    I tried this solution and it didn't work for me. I think it is because of the new version of Unity (3.5.5f3)

    This is what works with this version of Unity:

    Code (csharp):
    1. if(iPhone.generation == iPhoneGeneration.iPodTouch3Gen)
    2. {
    3.     print ("iPodTouch3G detected!");
    4. }
    Just change iPhoneSettings for iPhone. :)
     
  9. unity fly

    unity fly

    Joined:
    Jul 26, 2013
    Posts:
    2
    Hi,

    Is All iPod Generations have same Display resolution or Different ? Can you Confirm me ? Thank you In Advance.
     
  10. Agent_007

    Agent_007

    Joined:
    Dec 18, 2011
    Posts:
    899