Setting up the Unity project

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:

  1. Let’s create a new project, and we will call it Chapter4 or Sound of Flowery Prose:
  1. Next up, we need to click on the store and search for ARKit to download and add it to our project:
  1. 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:
  1. Drag the camera into the CameraParent empty game object:
  1. 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:

  1. 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.
  2.  The Unity AR Video also needs a clear material, so let’s set that to be YUVMaterial:

  1. ARCameraManager needs the appropriate script attached to it – in this case, it is called the Unity AR Camera Manager:
  1. ARKitControl also needs a script attached to it, and it is called Unity AR Kit Control:
  1. 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.
  2. Click on the Cube object and select Add Component | Script | New Script. The name should be ARHitCube:
..................Content has been hidden....................

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