游戏邦在:
杂志专栏:
gamerboom.com订阅到鲜果订阅到抓虾google reader订阅到有道订阅到QQ邮箱订阅到帮看

如何将游戏从Unity导到iOS设备上

发布时间:2014-09-25 11:17:07 Tags:,,,,

作者:Thaleia Deniozou

当我开始开发自己的iOS游戏时,我会考虑的第一件事便是如何将其导出到设备中,如此有效地测试我的游戏。最初,该过程看似很长且复杂,我所遇到的主要问题是,尽管存在许多资源,但是它们并非完全来自同样的地方,所以我不得不通过各种教程将其组合并匹配在一起。所以我决定通过本文一步步地总结这一过程。这是我到目前为止所遵循的一些方式;希望这也能够带给处于同样开发阶段的人更多帮助。

让我们开始吧。

develoers(from apple)

develoers(from apple)

1.获得Unity和iOS导出器

如果你还未这么做,你首先需要在官网下载最新版本的Unity。已经出现了2个版本,分别是免费版(http://unity3d.com/unity/download)和Pro版(https://store.unity3d.com),所以你可以根据自己的需求做出选择。自从2013年5月以来,手机便自带导出器,所以你无需为它们再花钱了。

2.注册苹果开发者计划

你需要做的下一件事便是加入苹果开发者计划,这是设定你的开发认证的必要过程。加入该计划每年需要支付99美元,你将需要通过以下开发者网站进行注册:https://developer.apple.com/programs/ios/(一旦你完成了注册并支付了费用,你便会收到一封激活邮件帮助你加入该计划并让你能够使用自己所需要的所有功能)。

3.下载并安装XCode

加入开发者计划后的下一件事便是下载并安装XCode。这在一开始可能会让人困惑,你们中的有些人会知道XCode是用户为iOS创造原生应用。而Unity使用XCode作为中介将内容带劲iOS设备中,所以你并未真正进入XCode,所有的开发将是发生在Unity上,XCode的作用是将内容从Unity导入设备中。你可以从苹果商店中下载XCode:https://developer.apple.com/xcode/。完成下载后请确保在继续下一步前安装好它。

4.创造一个开发者配置文件

到目前为止你应该已经下载了Unity和XCode并激活了你的苹果开发者计划会员。现在,为了将你的游戏直接从Unity导到设备上,你需要一个开发者配置文件(这将让你能够移植你所开发的游戏或任何测试到你的设备上)。苹果提供了两种类型的配置文件,即用于开发和测试的开发者配置文件以及用于提交到苹果商店的分布配置文件。为了创造开发者配置文件,你需要做3件事:注册你的设备/建立一个应用ID/获得证书。

你可以通过你的苹果开发者计划完成这三件事。所以导航至这一地址: https://developer.apple.com/ ,然后从最上方的菜单进入会员中心。使用你的苹果ID和密码登录。

现在选择Certificates, Identifiers和Profiles,你便能够从中访问并管理你的配置文件,苹果ID等等。

1)注册你的设备

在Certificates, Identifiers和Profiles部分中选择设备。因为这对于苹果去识别用于测试的特定设备是必要的。这并不会改变你的设备的任何设置,你能够轻松地使用自己每天所使用的设备。在注册你的设备时,你可以点击+按键去添加一个新设备。然后你需要填写设备的名字(可以是任何名字)以及UDID(即设备独一无二的ID)。你将会发现自己可以注册一个以上的设备进行测试,如果你想要基于不同设备进行测试的话这边很有帮助(如一台iPhone和一台iPad)。

为了找到你的设备的UDID,你需要将你的设备与电脑连接在一起,然后打开iTunes并点击iPhone按键(界面的右上方的),你将看到设备的信息包含了名字。然后你可以将鼠标停在上方并点击Serial Number,这将变成一个常标识,这便是UDID。

这是你需要的数字,你必须将其复制黏贴到Member Center Portal的ID部分。现在你便可以注册你的设备了。记住一旦你注册了设备,你便只能改变它的名字而不能改变UDID。

2)设置一个应用ID

下一步便是设置你的应用ID。仍然在Member Center Portal的Certificates, Identifiers和Profiles,选择应用ID并点击+按键。

首先提供任何你想要的描述,只要它能够帮助你记得你的ID是用于做什么便可。一个好的方法便是为一款应用使用一个独特的名字并为一款测试应用使用一个普通的名字。接下来你需要设置Bundle Identifier,这是以相反的域符号形式呈现出来“

即:com+你的全名(如果你是一名个体开发者的话)+你的游戏名称:

com.YourName.TheGameName

这类型的Bundle ID将很清楚并只能用于唯一的一款游戏中。因此你需要为你的每一款游戏使用不同的名字。然而这是很有用的,这让你能够访问像“游戏中心”和“应用内部购买”等服务。

另一方面,Wildcard的Bundle ID是以如下形式呈现出来:

com.YourName.*

这里用星号替代了游戏名字。这种格式让你能够在多款应用中使用同样的ID,而无需每次都设置一个不同的名字,但是这却不允许你使用特定的设备。

现在你已经选择了继续并确认了应用ID。将捆绑ID记录下来,因为之后你将需要在Unity的构建设置中使用到它。

3)获得开发者证书

你需要做的第一件事便是通过你的计算机获得Certificate Signing Request。前往Applications > Utilities > Keychane Access,然后是Preferences > Certificates。确保Online Certificate Status Protocol和Certificate Revocation List都是处于OFF,并关闭Preference。现在在Keychane Access中前往Certificate Assistant并从Certificate Authority中选择Request Certificate。提供与你在注册开发者计划时使用的同样细节并点击继续。提供一个名字并保存到Desktop。在保存时选择2048位体和RSA。

现在在你的Desktop中应该拥有一个带着.certSigningRequest前缀的文件。

现在回到Member Center Portal的Certificates, Identifiers和Profiles部分,选择Certificates > Development(就像你要获得开发证书那样),然后按压+按键进行创造。

选择上传你保存在Desktop中的Certificate Signing Request。在你提交前,确保向下滚动页面并在Intermediate Certificates中找到WWDR Certificate。在你之后需要的时候可以下载它。

现在进行提交,你的Certificate Signing Request将被发送到苹果并被另外一个你能够下载的内容所取代。它将被命名为:ios_development.cer

所以现在你的Desktop上应该拥有两个证书。即ios_development.cer和WWDR Certificate,你需要双击这两个证书将其安装于Keychane Access。现在你便设置好你的开发者证书了。

4)创造配置文件

在完成上述三个步骤后,现在的你可以继续去创造配置文件了。仍然在Member Center Portal的Certificates, Identifiers和Profiles中,前往Provisioning Profiles > All并按压+按键去创造一个全新的配置文件。

在Development和Distribution Profile中做出选择(这里我们需要的是Development!),然后在下一个屏幕上选择与该配置文件相联系的应用ID,设备和证书(游戏邦注:这是你在之前步骤已经设置好了的)。最后为配置文件命名并回顾之前的选择。当准备好时点击Generate。现在你便可以看到你的全新配置文件,你需要将其下载到你的Desktop上然后安装它。配置文件将是一个带有.mobileprovision前缀的文件。

现在转向XCode,前往Window > Organizer > Devices > Provisioning Profile,然后双击已经下载到你的Desktop上的配置文件。你便完成了安装并能够给予Organizer视图看到它。最后一步非常重要,因为只有将配置文件安装到Xcode,它才能够正常运行。

一些额外的内容:仍然在XCode,如果你的设备在Devices视图中仍看不到,那就前往Window > Organizer > Devices,按照名字选择设备。你可能需要在这个过程中选择Use for Development,然后提供你的开发者记录细节。

虽然这是一个较为漫长的过程,但好消息是你已经完成工作了!

现在你可以开始致力于你的Unity游戏并准备好导出它。

记得你只能注册设备和创造开发者证书一次,每当你创造一款新游戏时你都需要创造一个全新的应用ID和全新的配置文件。

5.面向Unity

当你准备好导出你的游戏时,前往File > Build Settings,并确保你选择了iOS作为平台。记得包含当前场景到导出游戏中(使用Add Current按键)。然后点击Player Seetings按键并前往Other Settings。

将Bundle Identifier按照你之前设置好的进行设置(com.YourName.TheGameName),你可能需要将Target IOS版本设为6(或者你的设备的版本)。将所有内容都保持为默认,除非你有改变它们的理由。

然后回到Build Settings Window并点击Build然后将项目保持到其自身的文件夹中。

连接你的设备和计算机,打开文件夹并开始XCode项目。你将看到它在XCode中打开。从XCode界面的左上角选择你的设备,然后点击Run按键。

项目将给予你的设备进行创建并自动运行(确保你的设备是打开的!)

就是这样了!现在你的游戏已经能够运行于你的iOS设备上了。

本文为游戏邦/gamerboom.com编译,拒绝任何不保留版权的转功,如需转载请联系:游戏邦

Export from Unity to an iOS Device

by Thaleia Deniozou

One of the first things I had to look into when I started developing my iOS game was how to export to the device so as to be able to test the game. Initially the process seemed long and complex and the main issue I had was that although the resources where all out there, they were not all in one place and so I had to mix and match from various tutorials. Here I will therefore summarize the process step by step in a single post. This is the process I followed to set everything up and has worked fine for me thus far; so hopefully it will be of assistance to people in a similar stage of development.

Here we go…

1. Get Unity and the IOS exporter

If you haven’t done this already you first need to download the latest version of Unity via the official website. There are two versions available, the free (http://unity3d.com/unity/download) and the Pro version (https://store.unity3d.com/), so you can choose one according to your needs. Since May 2013, the mobile exporters come with and you no longer have to pay for them.

2. Register for the Apple Developers program

The next thing that you will have to do is join the Apple developers’ program which is essential for setting up your development certificates among other things. Joining the program will cost $99 per year and you will need to register via the developers website here: https://developer.apple.com/programs/ios/ (Once you have registered and payed your fee, you will receive an activation e-mail which will allow you to fully join the program and give you access to all the features that you need).

3. Download and install XCode

Having joined the developers program the next thing to do is download and install XCode. This may seem confusing at first, as some of you will know that XCode is used for building native apps for the IOS. What happens is that Unity uses XCode as a mediator to push things into the IOS device, so you will not be actually working in XCode, all of the development will happen in Unity, however XCode is needed for exporting from Unity to the device. You can download XCode from https://developer.apple.com/xcode/ from the Apple Store. When done, make sure to install it before continuing.

4. Create a Developer Provisioning Profile

So far you should have downloaded Unity and XCode and activated your Apple developer program membership. Now, to export your game directly from Unity to the device you will need a Developer Provisioning Profile (which will authorize you to port the game you have developed or any tests, to your device). Apple offers two types of signed profiles, the Developer Profile, used for developing and testing (the one discussed here) and the Distribution Profile, used for submitting to the Apple Store (which is not covered in this post). However to set up the Developer Provisioning Profile you will need three separate things: to register your device / to set an App ID / and to get a Certificate.

All three can happen via your Apple Developer profile. So navigate to this address: https://developer.apple.com/ and then from the top menu go to Member Center. Use your Apple ID and Password to log in and then you will see a screen similar to this one:

Now go and select the Certificates, Identifiers and Profiles from where you can access and manage your provisioning profiles, apple IDs etc.

i. Register your Device

When in the Certificates, Identifiers and Profiles section, select Devices. The reason why this is needed is for Apple to be able to identify the specific device which will be used for testing. This will not alter any of your device’s settings and you can easily use the regular device you use everyday. To register your device hit the + button to add a new device. You will then need the device’s Name (which can be anything you want) and the UDID (which is the device’s unique ID). As you’ll see you can register more than one devices for testing, which could be useful if you’d like to test on more than one device (e.g. an iPhone and an iPad).

To find your device’s UDID you will need to connect your device to your computer, then open iTunes and hit the iPhone button (upper right corner of the interface) and you’ll see your device’s info including the name. Then hover over and click on the Serial Number which will change to a long identifier, the UDID.

This is the number you need so make sure to copy-paste it in the ID section in the Member Center Portal. Now review and register your device. Remember that once you register the device you can then only change its name and not the UDID.

ii. Set up an App ID

The next step is to set up your App ID. Still in Certificates, Identifiers and Profiles in the Member Center Portal select App IDs and hit the + button.

First provide the Description which can be anything you want as long as it helps you remember what the ID is used for. A good practice is to use a unique name for an app you plan to use and a generic one for a testing app. Next you need to set up the Bundle Identifier which takes the form of a reversed domain notation:

This is: com followed by your full name (if you are an individual developer) and your game’s name:

com.YourName.TheGameName

This type of Bundle ID is an Explicit one and is used for only one game. Therefore you will have to use a different name for every game you make. However it is useful and it allows you to access services like the ‘Game center’ and the ‘In-app purchases’.

On the other hand a Wildcard Bundle ID take the following form:

com.YourName.*

Here the game name is replaced by an asterisk. This format allows you to use one ID for multiple apps, without having to set a different name everytime, however it does not allow you to use certain services.

Now you have made your selections hit continue and confirm the App ID. Take a note of the Bundle ID as you’ll need to use it in Unity’s Build Settings later.

iii. Get a Developer Certificate

The first thing to do to get a Developer Certificate is to get a Certificate Signing Request through your computer. Go to Applications > Utilities > Keychane Access and then Preferences > Certificates. Make sure that both Online Certificate Status Protocol and Certificate Revocation List are OFF and close Preferences. Now in Keychane Access go to the Certificate Assistant and select Request Certificate from Certificate Authority. Provide the same details as the ones you used to register for the developer’s program and hit continue. Provide a name and save to Desktop. If asked choose: 2048 bits and RSA when you save.

You should now have a file with a .certSigningRequest prefix on your Desktop.

Now back Certificates, Identifiers and Profiles in the Member Center Portal, select Certificates > Development (as you are about to get a Development Certificate) and hit the + button to create one.

Choose to upload the Certificate Signing Request you have saved on your Desktop. Before you submit it, make sure to scroll down the page and find the WWDR Certificate in Intermediate Certificates. Download this as you will need it later!!

Now Submit and your Certificate Signing Request will be send to Apple and replaced by another one which you can download. This one is named: ios_development.cer

So now you should have two certificates on your Desktop. The ios_development.cer and the WWDR Certificate and you need to double-click on both of them to install then in Keychane Access. That’s it, you now have your developer certificate set up and installed.

iv. Create the Provisioning Profile

Having done the above three steps you can now go ahead and create your Provisioning Profile. Still in Certificates, Identifiers and Profiles in the Member Center Portal go to Provisioning Profiles > All and hit the + button to create a new profile.

Choose between a Development and a Distribution Profile (here we need a Development one!) and on the next screen choose the App ID, the device and the certificate associated to this profile (these are the ones you set up on previous steps). Finally name the profile and review the selections. When ready, hit Generate. Your new Provisioning Profile will now be available and you need to download it to your Desktop and install it. The profile will be a file with the prefix: .mobileprovision

Now start XCode and go Window > Organizer > Devices > Provisioning Profile and then double click on the profile downloaded on your desktop. It will be installed and should be visible in the Organizer view. This last step is very important as the profile must be installed into XCode to properly work!

Something Extra: While still in XCode if your device is not visible in the Devices’ view go to Window > Organizer > Devices and choose a device by name. You may have to select Use for Development in the process, and provide your developer’s log in details.

OK that was a long process but the good news is that you’re done!

You can now start working on your Unity game and be ready to export it once done!

Remember that you register your device and create a developer certificate only once, but you need to create a new App ID and a new Provisioning Profile everytime you make a new game.

5. Working in Unity

When you are ready to export your game, go to File > Build Settings and make sure you select IOS as your platform. Remember also to include the current scene to the exported game (use the Add Current button). Then hit the Player Settings button and go to Other Settings.

Set the Bundle Identifier to be the one you set up earlier ( com.YourName.TheGameName ) and you may also have to set the Target IOS Version to 6 (or the version your device is using). Leave everything else as default unless you have a reason to change it.

Now back to the Build Settings Window hit Build and save the project on its own folder.

Connect your device to your computer, open the folder and start the xcode project. You’ll see it opening inside XCode. Select your device from the top left corner in the XCode interface and then hit the Run button.

The project will be build on your device and run automatically (make sure your device is unlocked!).

And there it is! Your game is running on your IOS device.(source:gamasutra)

 


上一篇:

下一篇: