OUYA Game Development by Example
上QQ阅读APP看书,第一时间看更新

Time for action – importing packages into a new workspace

Now that you have all of the packages required for OUYA development, you can import them into the Unity workspace by performing the following steps:

  1. Start a new project in Unity and double-click on the core package you exported to import it into your workspace. Unity will prompt you with a list of possible items to import; make sure they're all checked and click on Import. The OUYA menu will re-appear along the top toolbar as soon as the import completes.
  2. Open the Window menu along that toolbar and click on Open OUYA Panel.
  3. This window is where we'll finally link all of the packages we've downloaded so far to the engine. The panel also has a space to link an NDK, which we will download and link to last.
  4. The Unity tab will automatically contain what it needs, so first click on the Java JDK tab and browse to the location of your JDK, as shown in the following screenshot:
    Time for action – importing packages into a new workspace
  5. Next, click on the Android SDK tab and do the same. Note that it may not be as automatic as the Java process as the locations of files in the SDK tend to change; if that happens, locate the files at their new location and move them to the potential locations displayed in gray. As long as you downloaded all of the packages listed earlier in the chapter, you have the files; they just might not be in the place Unity expects them to be.
  6. Also, check the minSDKVersion value that's at the top of the Android SDK tab. If it's not set to 16 (currently the supported SDK version for OUYA), you'll have to click on Edit, then move the mouse over Project Settings and click on Player. This will display your player settings in the Inspector window on the right-most pane of the Unity environment, where you can change the Minimum API Level to 16 (Android 4.1) under the Other Settings tab. Make sure you're viewing the Android tab at the top of the Inspector window:
    Time for action – importing packages into a new workspace

    Once every path to the Android SDK is set, you just need to download and link to the Android NDK. The Android NDK tab has a link at the bottom to download the required package.

  7. Download the proper version from the site it opens and store it in your development folder so that its path is Development/android-ndk-r8d. Link to this location in the OUYA panel window, as shown in the following screenshot, by browsing to that location and it should find the necessary files automatically.
    Time for action – importing packages into a new workspace

What just happened?

The last step in setting up your development environment is linking your engine to the API that you'll be working in. The OUYA panel that you added to Unity using the OUYA Unity plugin serves as a sort of checklist organized into tabs, making sure you have every package necessary to build to the OUYA. The Java JDK is necessary for Unity and the Android SDK Manager to run. The Android SDK is the main package, as it includes code necessary for any project to run on Android.

The NDK that you downloaded and linked is a secondary Android package that isn't always necessary for Android projects but will be for OUYA projects. It enables the execution of low-level code that we won't need to deal with but is still necessary for "under-the-hood" operations. The following table lists various packages and their purpose:

Pop quiz – small parts of a whole

Q1. What should the minimum API level of your Unity Android project be to properly deploy to the OUYA?

  1. API level 18 (Android 4.3)
  2. API level 11 (Android 3.0)
  3. API level 16 (Android 4.1)
  4. API level 15 (Android 4.0.3)

Q2. What package needs to be imported in order to display the OUYA panel in the Unity workspace?

  1. StarterKit Package
  2. Core Package
  3. Examples Package
  4. NGUI Package