Unity Setup
- Download and install Unity. The personal edition is fine for this class.
- Download and install Java 8 SE JDK
- Download and install Android SDK.
- Download the Cardboard SDK for Unity by clicking the “Direct Link to Unity Package.”
- Open Unity app. Create an account if necessary, and create a new project called HelloUnity. Make sure you choose 3D project.
- On the Menu Bar, select Unity -> Preferences -> External Tools
- This gets a little bit tricky on the Mac… You need to tell Unity where the Java JDK and the Android SDK are located, but both of these are buried in hidden folders. You will need to open up Terminal to find these folders and set them in Unity.
- In Terminal, run the following commands:
- chflags nohidden /Library
- chflags nohidden ~/Library
- The library folders are now visible in the finder.
- The Android SDK is located at ~/Library/Android/sdk
- The Java JDK is located at /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
- Install the Cardboard SDK. On the Menu Bar, go to Assets -> Import Package -> Custom Package… and select the Cardboard SDK Unity Package.
- Choose “Import All”.
- In the Project window’s Assets folder, go to Cardboard/Prefabs.
- Drag the CardboardMain prefab into the hierarchy.
- Delete the original MainCamera from the hierarchy.
- Select CardboardMain in hierarchy and set position to 0,1.6,0. This moves the camera up to around 1.6 meters, a good average height for a human’s eyes.
- You are now ready to build your VR scene.
- When you are done and are ready to export to an external device, go to the menu bar and choose File -> Build Settings…
- Select Android Platform and choose Switch Platform.
- When platform switch is done, choose Player Settings… from the build window.
- Most of the defaults are fine, but you will need to change some player settings.
- Company Name: Anything you like (let’s use NYU IDs)
- Product Name: the name that will appear on the phone’s Home Screen
- Go to “Other Settings”
- bundle Identifier: reverse URL. It needs to be unique and by convention is the company’s website + the product name. We can make it something like edu.nyu.itp.ck987.terrain . Alphanumeric characters only. No hyphens.
- Minimum API level: Android 4.4 KitKat (Api level 19)
- Resolution and Presentation:
- Orientation/ Default Orientation: Landscape Left (this will keep the image from Auto-Rotating)
- Plug in your Android Phone to your computer’s USB port.
- You may need to turn on developer mode and enable USB Debugging. If Unity is complaining that it can’t find the phone, follow these directions to enable developer Mode.
- After Developer Mode is enabled, you should see “Developer Options” in your phone’s Settings App. In the Developer Options you can enable USB Debugging.
- Choose Build and Run. Save the APK. I like to save the APKs to a separate folder so that the APK doesn’t get bundled into my project. But it’s up to you.
- If everything is set up correctly, your scene should show up on your phone! The app is also installed on the phone and can be started like any other app.