Search Unity

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

November 1, 2012 in Technology | 3 min. read
Topics covered
Share

Is this article helpful for you?

Thank you for your feedback!

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.

November 1, 2012 in Technology | 3 min. read

Is this article helpful for you?

Thank you for your feedback!

Topics covered