Preparing an Android Unity project

Now that we have the Android side of things taken care of, we need to get our project ready to build for an Android device.

To begin, we need to:

  1. Open the Build Settings. You can find this by navigating to the top menu: FileBuild Settings or via the keyboard shortcut Ctrl + Shift + B (or command + Shift + B on a Mac).
  2. Highlight Android from the list of platforms on the left.
    • You will see, if you haven't already (as in the following image), that you need to install the Android Module for Unity (~116mb). Therefore, click Open Download Page, download it to an ideal location, and install it.
    • If you already have it installed, then click Switch Platform, located in the bottom left of the dialogue box:
  1. Once you have done that, you will need to restart Unity so that the module will load. After you have done this, you will see the following screen with an array of different options for building on an Android device:
  1. Then, you need to click on the Player Settings… button. You will have in the Inspector all the settings to export your game and to build it on a specific platform. You can set the name of your company, and the name of the game, as well as an icon. In particular, if you select the Android tab, you will have four sub-tabs, as shown in the following screenshot:

  1. If you open the Other Settings tab, you will have many options. The most important ones, at least to have a successful build, are under the Identification label. These settings allow you to uniquely identify your game and set the requirements to make it run. The Package Name should be in the form com.YourCompany.YourGameName, a unique identifier. Be sure to change it before you do any builds:

The other options under Identification are pretty straightforward. Remember that it is important to change and/or update the version of your game every time you publish an update.

After you have finished that, you can come back to the build menu. If you click on the Switch Platform button, the Unity Logo will move next to Android, as shown in the screenshot. Keep in mind that the process might take several minutes, depending on the size of your project:

Finally, you will need to add scenes into the build by dragging and dropping them to the preceding space. In the following screenshot, I'll insert Level1 and Level2 (which I created):

One last thing before we export the game. We need to decide if this is a Development Build or not. Since our game has just two levels, and we want to add more to it before we release it, we can check the Development Build checkbox. This way, not only will the Development Build appear, but you will have access to a series of debug tools (outside of the scope of this book) that were otherwise not available. In fact, once checked, you will have another three checkboxes for these debug tools:

Now, you are ready to export by pressing the Build button. Unity will ask you where to export the .apk file to. Once you do this, you can import it to your phone in any location and install it.

If this is the first time you've developed for an Android phone, you might want to enable Install from Unknown sources in the developer options on your phone. Modern Android systems might redirect on that option when you try to install a .apk, such as the game you have just built. However, on older Android systems, you need to enable the developer mode. How to enable it might depend on your phone, but usually, you do it by tapping seven times on the build version in your system info (as explained earlier in the chapter).
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset