Categories & Tags
Archive

Unity’s ready for the iPad4 and new iPad Mini!

November 1, 2012 in Community News and Info, Technology, Unity Products and Services by

iOS developers around the world are waiting impatiently for Friday, November 2, when the new iPad4 and iPad Mini ship. The iPad4 promises improved CPU and GPU performance, meaning you can develop even more beautiful content for it. The iPad Mini introduces new physical dimensions for the screen with ~160 ppi, so it might require some minor fine-tuning of human interface design.

We are happy to announce that you can already begin designing your cool content for the new iPads with today’s release of the Unity 4 beta. The Unity 4 beta is perfectly tuned to make it easy for you to detect which device your game is running on. Both devices will also work out-of-the-box with Unity 3.5.6 and in this blog we will share a small snippet of plugin code that 3.5.6 developers can use until we update a couple of 3.5.6 APIs.

Before going straight to the code we would like to say thanks to our friends at Apple who kindly shared how iPad Mini and iPad4 can be distinguished from older iPads.

There are two main API entries in Unity that help you tune your game to specific iOS device features. They are Screen.dpi and iPhone.generation. Out of the box these will work with Unity 4.0 Open Beta, but Unity 3.5.6 runtime will detect iPad Mini as 2nd generation iPad and the iPad4 as a 3rd generation device. This will let most of the games work without any change, but as mentioned above, some of you might want a more fine-grained control on things. There comes simple iOSInfo plugin code package for Unity 3.5.6, which is not aimed to completely replace Screen.dpi and iPhone.generation APIs, but more like complement it until these changes get included into official Unity 3.5.x releases.

Installation and use instructions for Unity 3.5.6 are straightforward:

  1. Download iOSInfoPlugin_for_Unity_3_5_6.unitypackage;
  2. In Unity Editor 3.5.6 click Assets->Import Package->Custom Package.. and select just downloaded file; (Make sure all the files are selected for import)
  3. Start using the code. iOSInfo plugin offers four API entries:
    • iOSInfo.isIPadMini – this property evaluates to true when running on iPad Mini;
    • iOSInfo.isIPad4Gen – this property evaluates to true when running on 4th generation iPad;
    • iOSInfo.dpi – this property provides float number with dpi estimation for current device. It effictively can be used instead of Screen.dpi.
    • iOSInfo.GetDeviceModel() – this method provides string with raw hardware ID of the device, like iPad2,5.

Most likely your code will look like this:

if (iPhone.generation == iPhoneGeneration.iPad2Gen || iOSInfo.isIPad4Gen)
{
// Enable some awesome feature
}

or like this:

if (iOSInfo.dpi < 160.0f)
{
// Resources.Load(“small_dpi_asset”);
}
else if (iOSInfo.dpi < 260.0f)
{
// Resources.Load(“medium_dpi_asset”);
}
else
{
// Resources.Load(“high_dpi_asset”);
}

With Unity 4.0 Open Beta it is even simplier. Your code probably will look like this:

if (iPhone.generation == iPhoneGeneration.iPad2Gen ||
    iPhone.generation == iPhoneGeneration.iPad4Gen)
{
// Enable some awesome feature
}

or like this:

if (Screen.dpi < 160.0f)
{
// Resources.Load(“small_dpi_asset”);
}
else if (Screen.dpi < 260.0f)
{
// Resources.Load(“medium_dpi_asset”);
}
else
{
// Resources.Load(“high_dpi_asset”);
}

Edit: updated iOSInfo plugin download URL, I hope this one works more reliably.

Share this post

Comments (30)

Comments are closed.

hippo
1 Nov 2012, 4:13 pm

404 on link.

hippo
1 Nov 2012, 4:14 pm

It’s ok now guys! Will this eventually be integrated in 3.5.x ?

Ishsaid
1 Nov 2012, 4:26 pm

Which iOS SDK would we need to have for these?

Paul
1 Nov 2012, 4:35 pm

Guys, getting 404 on that download link.

Cheers

ikumajp
1 Nov 2012, 6:38 pm

Excellent! Can’t wait!

John
1 Nov 2012, 9:23 pm

Unity 3.5 owners are now 2nd class and slumming it……interesting way to get us to pay 6k more to and the “pro” keys we already purchased. Go Unity!

1 Nov 2012, 9:32 pm

@John: seriously? Same out of the box new iPad models support will come into Unity 3.5.7. Here we’re providing a way to achieve that in the already released version (3.5.6).

JDMulti
2 Nov 2012, 12:46 am

Interesting, I was already wondering how this would get supported in the current version of Unity. I’m glad that even 3.5.x users are getting this candy. Some other software companies just ignore support for older versions, if there is another version coming. Thanks =)

Mantas Puida
2 Nov 2012, 1:18 am

@hippo, @Paul : are you still getting 404? I can’t reproduce this..

Mantas Puida
2 Nov 2012, 1:20 am

@Ishsaid: it does not depend on specific SDK version, but most likely you will need Xcode 4.5 to deploy to new devices.

Guillermo
2 Nov 2012, 3:00 am

Getting 404 error on download link

Angelo
2 Nov 2012, 3:19 am

Tried right now, getting 404 too.

Mantas Puida
2 Nov 2012, 3:21 am

@Angelo, @Guillermo: I just updated download url. Could you please refresh the site and try once again?

Guillermo
2 Nov 2012, 3:30 am

Thanks Mantas, is working now ;)

Angelo
2 Nov 2012, 3:54 am

Thank you very much Mantas, got it now!

ratamorph
2 Nov 2012, 7:16 am

I’m a bit confused, Say I don’t do any of this, since my game is already in Apple QA. The new devices will report as unknown, which in my case assumes is a new device so it applies all effects and such. No aspect ratio changes like for iPhone 5, so what exactly should I be watching for? or is this just if we wish to modify the UI somehow for the smaller iPad?

Mantas Puida
2 Nov 2012, 7:53 am

@ratamorph : your assumption is slightly incorrect. It won’t be “Unknown”. If you do nothing (assuming you are using Unity 3.x) then iPad4 will be detected as iPad3 and iPad Mini as iPad2. It depends how your game treats iPad3 then..

ratamorph
2 Nov 2012, 8:03 am

@Mantas: performance wise it should be no problem as the games runs pretty well on ipad2. I was wondering more about things looking out of place or any other issues that might come up when a user runs my game build on 3.5.6 on an ipad mini.

Mantas Puida
2 Nov 2012, 9:36 am

@ratamorph : I believe all the objects should remain in place on iPad Mini.

golden_gate
2 Nov 2012, 12:41 pm

@Aras Pranckevičius Thanks so much for the hard work to make Unity iOS compatible with the new Apple Products. As a iOS Pro user with a significant investment his would be my expectation.

The e-mail that I received stated : “We have been working together with Apple to make sure the Unity 4 beta is ready in time for the releases of the new iPad and iPad mini.”

Its great that you have worked with Apple to make the necessary changes for the iPAD mini and iPAD 4 but when are we going to work with Apple to update the Unity iOS Pro rendering pipeline. Its been over a year and a half since Apple introduced the iOS 5 API CVOpenGLESTextureCache. Are we working on this or has Unity abandoned Apples API enhancements in lieu of GPU/CPU hardware updates. We need Unity iOS Pro API compatible with Apple iOS’s… not just hardware. What good is a powerful CPU/GPU with antiquated Unity iOS 5 API support??

Andrea Leganza
2 Nov 2012, 1:16 pm

Why don’t add a zoom slider to let resize the player area to avoid the need of bigger screen to test on “small” monitors for new iPad/iphone 5?

Sean Hart
2 Nov 2012, 2:12 pm

We seem to be having issues with Unity being able to import the zip file, and if we unzip the files then we don’t really know where to put those files in our project. Can you re-upload the .zip file as a .unitypackage file, or tell us where to put the files manually? Thank you.

3 Nov 2012, 7:06 am

@Hart, it’s not so, unzip the file you downloaded to import the .unitypackage file contained in the zip file.

4 Nov 2012, 7:26 am

sounds like a hardware issue, try to reset the network settings

Mantas Puida
5 Nov 2012, 4:47 am

@golden_gate: we do have plans for CVOpenGLESTextureCache extension in Unity 4.x release cycle and we would be very interested to get feedback on how it could help for you projects.

Sean Hart
5 Nov 2012, 12:42 pm

It looks like it was an issue with the default zip program I had on my MacBook. Thanks.

Projection Matrix
5 Nov 2012, 4:27 pm

In the provided C++ file, char *machine = (char *)malloc(size + 1); is never free’d. Is the C# interop smart enough to free this memory? Or should that string be static instead? I changed the cpp to avoid this.

#define MAX_DEVICE_NAME 32;
static char g_szDeviceName[MAX_DEVICE_NAME] = { 0 };

extern “C” char* GetDeviceModel() {
if (g_szDeviceName[0] == 0) {
size_t size; // get string size by passing NULL
sysctlbyname(“hw.machine”, NULL, &size, NULL, 0);

//char *machine = (char *)malloc(size + 1);

sysctlbyname(“hw.machine”, g_szDeviceName, &size, NULL, 0);
g_szDeviceName[size] = 0;
}

return g_szDeviceName;
}

Mantas Puida
6 Nov 2012, 12:47 am

It is free’d by mono when it is invoked via PInvoke (DllImport) : http://www.mono-project.com/PInvoke#Strings_as_Return_Values

Rod
7 Nov 2012, 5:03 pm

Hey,

So it seems the reported DPI should be 163.0f not 167.0f?

jaycee
12 Nov 2012, 4:50 pm

does anyone have problems unzipping the folder? I get a bunch of empty folders when i tried extracting the zipped package. I also tried just deleting the .zip extension and then importing into unity but no luck there. Unity complains about unknown format. Btw, I have a mac.

Leave a Reply

Comments are closed.