unity 适配ipad_Unity为iPad 4和新款iPad Mini做好了准备!

unity 适配ipad

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.

全世界的iOS开发人员都在不耐烦地等待11月2日(星期五)新的iPad4和iPad Mini上市。 iPad4有望改善CPU和GPU性能,这意味着您可以为其开发更精美的内容。 iPad Mini以约160 ppi的分辨率为屏幕引入了新的物理尺寸,因此可能需要对人机界面设计进行一些细微的调整。

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.

我们很高兴地宣布,随着今天发布的Unity 4 beta版 ,您已经可以开始为新iPad设计出色的内容。 Unity 4 beta进行了完美的调整,使您可以轻松检测正在运行游戏的设备。 两种设备都可以与Unity 3.5.6一起使用,并且在本博客中,我们将共享一小段插件代码,供3.5.6开发人员使用,直到我们更新几个3.5.6 API为止。

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.

在开始编写代码之前,我们要感谢苹果的朋友们,他们亲切地分享了iPad Mini和iPad4与旧版iPad的区别。

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.

Unity中有两个主要的API条目,可帮助您将游戏调整为特定的iOS设备功能。 它们是Screen.dpiiPhone.generation 。 开箱即用,它们将与Unity 4.0 Open Beta一起使用,但是Unity 3.5.6运行时将把iPad Mini检测为第二代iPad,将iPad4检测为第三代设备。 这将使大多数游戏保持不变,但如上所述,某些人可能希望对事物进行更细粒度的控制。 对于Unity 3.5.6,有一个简单的iOSInfo插件代码包,其目的不是要完全替代Screen.dpiiPhone.generation API,而是要对其进行补充,直到这些更改被包含在Unity 3.5.x官方发行版中为止。

Installation and use instructions for Unity 3.5.6 are straightforward:

Unity 3.5.6的安装和使用说明非常简单:

  1. Download iOSInfoPlugin_for_Unity_3_5_6.unitypackage;

    下载iOSInfoPlugin_for_Unity_3_5_6.unitypackage ;

  2. Start using the code. iOSInfo plugin offers four API entries:

    开始使用代码。 iOSInfo插件提供了四个API条目:

    • iOSInfo.isIPadMini – this property evaluates to true when running on iPad Mini;

      iOSInfo.isIPadMini –在iPad Mini上运行时,此属性评估为true

    • iOSInfo.isIPad4Gen – this property evaluates to true when running on 4th generation iPad;

      iOSInfo.isIPad4Gen –在第四代iPad上运行时,此属性评估为true

    • iOSInfo.dpi – this property provides float number with dpi estimation for current device. It effictively can be used instead of Screen.dpi.

      iOSInfo.dpi –此属性为当前设备提供浮点数和dpi估计。 有效地可以代替Screen.dpi使用

    • iOSInfo.GetDeviceModel() – this method provides string with raw hardware ID of the device, like iPad2,5.

      iOSInfo.GetDeviceModel() –此方法为字符串提供设备的原始硬件ID,例如iPad2,5

Most likely your code will look like this:

您的代码很可能看起来像这样:

1

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

1

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

or like this:

或像这样:

1

2
3
4
5
6
7
8
9
10
11
12
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”);
}

1

2
3
4
5
6
7
8
9
10
11
12
if ( iOSInfo . dpi & lt ; 160.0f )
{
// Resources.Load(“small_dpi_asset”);
}
else if ( iOSInfo . dpi & lt ; 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:

使用Unity 4.0 Open Beta甚至更简单。 您的代码可能如下所示:

1

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

1

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

or like this:

或像这样:

1

2
3
4
5
6
7
8
9
10
11
12
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”);
}

1

2
3
4
5
6
7
8
9
10
11
12
if ( Screen . dpi & lt ; 160.0f )
{
// Resources.Load(“small_dpi_asset”);
}
else if ( Screen . dpi & lt ; 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.

编辑:更新了iOSInfo插件下载URL,我希望这一工作更可靠。

翻译自: https://blogs.unity3d.com/2012/11/01/unitys-ready-for-the-ipad4-and-new-ipad-mini/

unity 适配ipad

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值