Search Unity

Enabling HD on iPad3

Discussion in 'iOS and tvOS' started by marjan, Mar 19, 2012.

  1. marjan

    marjan

    Joined:
    Jun 6, 2009
    Posts:
    563
    So for the guys who cannot wait here is a basic and not very elegant hack to enable HD on ipad3 in Unity3.5:

    Oben Appcontroller.mm in XCode and find bool CreateSurface(EAGLView *view, EAGLSurfaceDesc* surface). That should be arround line 317.
    In there you see an #ifdef __IPHONE_4_0 block. Thats basically what you need to do same way for ipad 3.

    So, behind this block paste the following:

    Code (csharp):
    1. if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad  [[UIScreen mainScreen] respondsToSelector:@selector(scale)])
    2.         //if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad  [[UIScreen mainScreen] respondsToSelector:@selector(scale)]  [UIScreen mainScreen].scale > 1)
    3.         {
    4.             // new iPad
    5.  
    6.                 // retina display
    7.                 int resolution = UnityGetTargetResolution();
    8.                 NSLog(@"[UIScreen mainScreen] scale] = %f, resolution = %i,", [[UIScreen mainScreen] scale], resolution);
    9.                
    10.             //if ((resolution == kTargetResolutionNative || resolution == kTargetResolutionHD)  [view respondsToSelector:@selector(setContentScaleFactor:)])
    11.                 if ([view respondsToSelector:@selector(setContentScaleFactor:)])
    12.                 {
    13.                     //CGFloat scaleFactor = [UIScreen mainScreen].scale;
    14.                     CGFloat scaleFactor = 2.0;
    15.                     [view setContentScaleFactor:scaleFactor];
    16.                     newSize.width = roundf(newSize.width * scaleFactor);
    17.                     newSize.height = roundf(newSize.height * scaleFactor);
    18.                     UnitySetInputScaleFactor(scaleFactor);
    19.                    
    20.                     NSLog(@"Using Retina");
    21.                 } else {
    22.                     NSLog(@"Not Using Retina, resolution = %i, kTargetResolutionNative = %i, kTargetResolutionHD = %i", resolution, kTargetResolutionNative, kTargetResolutionHD);
    23.                        
    24.                 }
    25.  
    26.         }
    Please note that i have a weird problem there. Basically we first test [UIScreen mainScreen].scale. On Retina Devices this value "should" be 2.0. But for some weird reason it returns 1.0 for me. I have no clue why. Well i got the new iPad today and still have xCode 3.2.5. Maybe it does work correctly under XCode 4.3 (i don´t want to use that now as i have to take care of older apps and don´t want to run into things like i can anly compile for ARM v7 or so)

    So, just to see if it basically works, i commented out the supposed to work if statements and set a hard 2.0 value.
    So, please be aware of this - cause this will break things for older ipads i guess.

    If somebody can tell me why i get [UIScreen mainScreen].scale = 1.0 on my iPad 3 i am eager to here about this.
     
  2. DavidButtress

    DavidButtress

    Joined:
    Aug 30, 2011
    Posts:
    32
    Just thought I'd confirm that you do get a scale of 2.0 using xcode 4.3.1, but using 4.3 it reports as 1.0. I'm guessing its designed like this so that old apps don't start rendering in the resolution without someone rebuilding them to support it.

    I've bodged in a fix so it checks the device type before hardcoding in the scale = 2.0; I use this code to check types https://github.com/erica/uidevice-extension/blob/master/UIDevice-Hardware.m
     
  3. marjan

    marjan

    Joined:
    Jun 6, 2009
    Posts:
    563
    Interesting....
    Strange, but interesting!
     
  4. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    Or you can just upgrade Xcode/SDK :)
     
  5. FiveFingers

    FiveFingers

    Joined:
    Oct 15, 2009
    Posts:
    541
    Or you can use your brand new iPad3 to fry some eggs&bacon according to the latest problems reported on the device, which is overheating a bit...

    Happy to have bought an iPad2...waiting for second batch of iPad3---
     
  6. marjan

    marjan

    Joined:
    Jun 6, 2009
    Posts:
    563
    well i have one for each. Ipad3 to fry eggs, ipad2 to cook noodles and i pad1 to cool drinks.
     
  7. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    Doesn't get any hotter than my 4S.
     
  8. chud575

    chud575

    Joined:
    Nov 19, 2010
    Posts:
    43
    guys, just goto player settings and set resolution to native. it works fine.
     
  9. Digitalfiend

    Digitalfiend

    Joined:
    Mar 5, 2012
    Posts:
    1
    Same here, no heat issues from my iPad 3 either.
     
  10. FiveFingers

    FiveFingers

    Joined:
    Oct 15, 2009
    Posts:
    541
    Wow that's talking!
    So If we make an Universal App and set Native Resolution, it will surely go Retina @x2 on the new iPad3 ?
     
  11. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    Yes. But to test on iOS 5.1 which comes standard on iPad3, you'll need to update your SDK (afaik)
     
  12. marjan

    marjan

    Joined:
    Jun 6, 2009
    Posts:
    563
    Hm,
    as native resolution is the default, i for sure used that and there was no HD output. From looking into the appcontroller i also cannot see why it should be enabled as there is only a check for iPhone4, which handles it (#ifdef __IPHONE_4_0). So either this is also letting the iPad3 through, which i doubt, or there are different appcontrollers compiled depending on which XCode version we run.

    If you say it works for you this way, i believe you. People with xCode 3.2 can get it to work the way i described then.

    And just for my interest: Is it true that you can only output armv7 with xcode 4.3 or can you still do the armv6 armv7 thing?
     
  13. RolfBertram_dot_me

    RolfBertram_dot_me

    Joined:
    Mar 1, 2011
    Posts:
    128
    Thanks for the tip! Works with Xcode4.3 and iPad3. However, it also seems to try to push HD graphics on iPad1, which makes that one crash. But for testing on iPad3 until Unity delivers a solution, it's great!

    Regarding arm6+7, I use it on Xcode4.3. Had to do a manual change to add arm6.
     
    Last edited: Mar 20, 2012
  14. FiveFingers

    FiveFingers

    Joined:
    Oct 15, 2009
    Posts:
    541
    And what are the downside in compiling the xcode project kicked out by unity on SDK 5.1 ?