Building and Testing the Game on Your iOS Device

Một phần của tài liệu Game Development for iOS with Unity3D 2012 (Trang 112 - 115)

5. Building a Game in Unity iOS: The Roll-a-Ball Game 73

5.4 Building and Testing the Game on Your iOS Device

in to turn them into a little more of an interesting play area. When you are done cre- ating a fun little maze, use the same technique to duplicate some hazards and place them around your level.

Get creative, test regularly, and have fun making a crazy level! To see the final level that I put together, feel free to jump ahead and open up the example file “rollaball_

complete” (Figure 5.21).

5.4 Building and Testing the Game on Your iOS Device

You’ve done the hard work (or perhaps you just went ahead and opened the “rollaball_

complete” project from the example files), and our ball-rolling game is as good as com- plete.

Now that we’re happy with how everything works in the editor, we can go ahead and make an iOS build to see how the game translates to the real device.

Open the project in Unity, if it isn’t already.

5.4.1 Add Your Bundle Name to the Player Settings

From within the Unity editor, click on the File menu. Now click on Build Settings. Check to ensure that the target platform is set to iOS. If it is not, select iOS from the list of platforms and click on the Switch Platform button.

Click the Player Settings button. Over in the Inspector window, the player settings will appear. Click Other Settings.

In the Identification section of the Inspector window, enter your bundle identifier into the Bundle Identifier box. The Bundle Version number is used to identify your build (bundle) version. Although you can put any number you like in here, it is best to start at a low number, like 1.0. Personally, I keep to 0.x numbers until I hit a release, then move

Figure 5.21. The final Roll-a-Ball game.

up to a 1.0. With each trivial release, such as bug fixes or minor additions, I increase the bundle version number by .1 until I reach 1.9 (when I move up to version 2), or if some- thing major is updated, such as adding a new level or a new game mode or something like that, I increase the bundle version to the next integer.

Keep your version numbers sensible (as in, don’t just go from a version 1 to ver- sion 6.2.5 to trick people into thinking you are working harder), because if you try to submit a version of the game to Apple that has a lower bundle version than a previous upload, it will be rejected.

5.4.2 Publishing to Your iOS Device

Now that we have some interactivity, we are all ready to publish to our device. The first steps to take are to make sure that we have the correct information for Unity to build with.

y Click on the File menu in the top left of the screen, followed by Build Settings.

In the Build Settings window (see Figure 5.22), check that the game scene ap- pears in the “Scenes in Build” window. If not, find and click the button under Scenes in Build labeled “Add Current.” What this does is add the scene to the build so that we can access it when the game runs on iOS. Only scenes in this list will actually be included in the final build, so it is important to check this before spending time building to the device. Another reason to keep an eye on

Figure 5.22. Build settings in the Unity editor.

5.4. Building and Testing the Game on Your iOS Device 97

this window is when you intend to load a scene from another scene, since the scene you are loading will need to be included in this list for Unity to recognize it.

y Double check that the platform is set to iOS. If not, select the iOS platform and click the Switch Platform button.

y Click the Player Settings button.

y The Inspector window will change to display player settings. Check that the iOS tab icon (the little iPhone icon) is selected to show iOS-specific settings.

y Click Other Settings.

y In the Identification section, check the box Bundle ID. This needs to match with the one you set up in the Apple Developer Center in Section 3.2.10 (e.g., com.yourcompanyname.yourgame).

y Set the target device to be the same type as your iOS device.

y Check that the Target iOS Version drop-down is reflective of the latest version of iOS. If you are unsure, click Unknown.

y At the top of the Inspector window, type “Hello World” into the Product Name field.

y Make sure that there are no errors in the Console. This will stop a build from being made. To bring up the Console, click the menu Window–>Console, or you can shortcut there with CTRL + SHIFT + C (CMD + SHIFT + C on a Mac).

y Warning messages are generally okay, but anything shown in red needs to be addressed prior to building.

There are a few more questions to consider at this point:

y Is your iOS device connected via USB cable?

y Did you download and install the required software outlined in Chapter 2 of this book?

y Did you set up and download all of the necessary certificates outlined in Chap- ter 2 of this book?

If the answer is no to any of the items above, refer back to Chapter 2 for setup informa- tion and check back here when it is rectified.

If it looks like you have covered everything in our little flight check, click on the menu File–>Build and Run. If this is the first time you have attempted to build, you will be prompted for a name and location to save the build. Choose a suitable location to save the project, noting that it is the Xcode project we are saving here and it should be kept away from your Unity project. Do not save your build within the “assets” folder of your project. Put it at the same level as the “assets” folder, or better still, save it into a new, appropriately named folder.

Don’t be alarmed if the build process appears to take a while—there is a lot go- ing on. Once it has successfully completed building your project, Xcode should open

automatically. Once Xcode has finished launching, it should automatically make a build of the project. If Xcode says “Build Succeeded” at the top of the window, we can go ahead and rebuild it for the device.

Before building to the device, ensure that the Scheme drop-down, which appears at the top of the Xcode window (Figure 5.23), is set to the name of your iOS device.

The Scheme drop-down may default to the iPhone Simulator, which is, of course, not where we want to build. If this is the case, click on the left side of the Scheme and select Unity—iPhone. If your device is connected via the USB cable and it has been set up cor- rectly for development, its name should appear in the drop-down from the right-hand side of the Scheme box. Click on the right-hand side to see a list of available options and select your device from the list.

Congratulations! You just found out how easy it is to build from Unity to iOS.

Một phần của tài liệu Game Development for iOS with Unity3D 2012 (Trang 112 - 115)

Tải bản đầy đủ (PDF)

(278 trang)