Magic Windows - Working with AR Kit

Setting up ARKit in unity


There is no plugin at the asset store! So go here:

The zipped file looks like a Unity Package, but it isn’t! You should copy its content to your project “Assets” folder.

Unity will update

Unlike Vuforia, Arkit doesn’t create a new Camera object, but uses Unity’s

·         Create an empty object named “Camera Parent”

·         Move the “Main Camera” to “Camera Parent” – making it ‘child’.

o   Main Camera – Inspector

§  Clear Flags: Depth Only

§  Culing Mask: Everything

§  Field of View: 60

§  Clipping Planes: Near: 0.1  / Far: 37.81

o   Add component: Unity AR Video

§  Material: YUVMaterial (or any clear material)

o   Add component: Unity AR Camera Near Far

·         Create empty object: ARCameraManager

o   Add component: Unity AR Camera Manager

§  Camera: Drag n drop the Main Camera

§  Plane Detection: Select if you want it to track planes on either horizontal or vertical or both. Sometimes you don’t want to track walls or the floor.

§  Get Point Cloud: toggle

§  Enable Light Estimator: Toggle

§  Enable Auto Focus: Toggle (YES!)

§  DONE!

ARKit is setup. Now setup the example scene

·         Create Empty Object “DebugViz”

o   Inside it create another empty object named: PointFinder

§  Add component: Unity Point Cloud Example

·         Increase Num Points to Show

·         Point Cloud Prefab: (grab example asset) PointCloudPrefab

§  Add another component to DebugViz: PlaneFinder

·         Add component: Unity AR Generate Plane

o   Plane Prefab: debugPlanePrefab (also part of the example collection)

Build for IOS

·         Player Settings

o   Bundle Identifier: add your company name:

o   Camera Usage Description: (Type whater you want to the user allow the use of the phone’s camera…..could be “ARBABY”…whatever.

o   Target minimum iOS Version:  11.0 (it has to be 11.0 or above)

o   Requires ARKit support: toggle

Open the project in XCode and go through all the usual Apple nuisance of adding team/your apple developer coder (automatic); connect a phone to your computer; authorize everything and if everything works you should have an icon with the Unity App in your phone.


Unity AR Hit teste example

·         Create empty object: hit_parent

o   Inside it create empty object: hit / OR…. Create a 3D object (exp: Cube) and ..

o   Add the “Unity AR Hit test example” script


§  Open the script

This script allows to detect if a touch on the screen is hitting one of the AR objects.

                Remove all the Update Unity part – from “#if” all the way to “else” and remove “endElse”. We don’t need it to run inside the unity player


                Remove comments for all ARHitTestResultType.xxxxxxx (activating them)


Build/ Compile and Run….it sort of works. A cube showed up and it stays in there…once. But no interaction.