The very first thing we are going to do is set Unity up on our Mac computer to be able to create our project. Since we know we will need ARKit, which only works on macOS, we will have different projects for the different chapters, as we don’t want any compilation issues:
- Let’s create a new project, and we will call it Chapter4 or Sound of Flowery Prose:
- Next up, we need to click on the store and search for ARKit to download and add it to our project:
- I am a bit of a stickler for organization, so we have to make sure to set up all the empty game objects we need to keep things organized. So, we will have four empty game objects called CameraParent, ARKitControl, ARCameraManager, and HitCubeParent. Your project should look like the one in the following screenshot:
- Drag the camera into the CameraParent empty game object:
- Create a Cube and drag the Cube into the HitCubeParent object:
Now that we have Unity basically set up as required, we can move on to creating and attaching the scripts we need for the project:
- Click on the Camera component – we have two scripts we need to add to it. The first script is Unity AR Camera Near-Far, and the second is Unity AR Video.
- The Unity AR Video also needs a clear material, so let’s set that to be YUVMaterial:
- ARCameraManager needs the appropriate script attached to it – in this case, it is called the Unity AR Camera Manager:
- ARKitControl also needs a script attached to it, and it is called Unity AR Kit Control:
- The final thing we need to do is set up our Cube from inside the HitCubeParent object to have a brand new script created for it.
- Click on the Cube object and select Add Component | Script | New Script. The name should be ARHitCube: