[PLEASE READ BEFORE YOU POST: We want to provide the best support we can afford to, but when there is a lot of noise on the forum, it gets harder to support legitimate issues. So please read the FAQ, and if possible read recent posts in the forum to see if your topic is covered already]
Unity ARKit plugin will provide developers with friendly access to ARKit features like world-tracking, live video rendering, plane estimation and updates, hit-testing API, ambient light estimation, and raw point cloud data.
All the features exposed by the ARKit are available from the C# scripting API within Unity. There are also Unity Components for easy integration of these features with existing Unity game projects. Please see the README.md file in the bitbucket repository for more info.
- Unity’s AR Kit plugin requires the release version of Unity 2017.1.0 or later. It is also compatible with the Experimental VR build used for macOS VR content creation and Unity 5.x versions of Unity 5.6.2 or later.
- Requires iOS 11 or later
- Requires XCode 9 beta or later, with iOS SDK that includes ARKit Framework
- Requires iOS device that supports ARKit (iPhone 6S or later, iPad (2017) or later)
Note: Xcode 9 beta 5 changed ARKit API and you have to update to latest version of our ARKit plugin to get things working again.
Our plugin is available as open source from https://bitbucket.org/Unity-Technologies/unity-arkit-plugin
Also available from the asset store.
Information from REAMDE.md in project:
Unity ARKit Plugin
This is a native plugin that enables using all the functionality of the ARKit SDK simply within your Unity projects for
iOS. The plugin exposes ARKit SDK’s world tracking capabilities, rendering the camera video input, plane detection and
update, point cloud extraction, light estimation, and hit testing API to Unity developers for their AR projects. This plugin is a preview quality build that
should help to get you up and running quickly with this technology, but the implementation and APIs may change to cater
to the underlying technology.
The plugin is open sourced and is released under the MIT license.
Requirements:
Unity 2017.1.0f3+ or 5.6.2+
iOS 11 Beta 7
Xcode 9 Beta 6 with latest iOS SDK that contains ARKit Framework
iOS device that supports ARKit
How to use this code drop:
The code drop is a Unity project that you can load up in any Unity version that is later than v5.6.2. The Unity
project contains the plugin sources and some example scenes and components that you may use in your own projects.
Here is a summary of the important files in the plugin:
“/Assets/Plugins/iOS/UnityARKit/NativeInterface/ARSessionNative.mm” - this is the Objective-C code that actually interfaces with ARKit SDK
“/Assets/Plugins/iOS/UnityARKit/NativeInterface/UnityARSessionNativeInterface.cs” - this the scripting API to the ARKit, and provides the glue to the native code
This contains the following APIs:
public void RunWithConfigAndOptions(ARKitWorldTackingSessionConfiguration config, UnityARSessionRunOption runOptions)
public void RunWithConfig(ARKitWorldTackingSessionConfiguration config)
public void Pause()
public List HitTest(ARPoint point, ARHitTestResultType types)
public ARTextureHandles GetARVideoTextureHandles()
public float GetARAmbientIntensity()
public int GetARTrackingQuality()
It also contains events that you can provide these delegates for:
public delegate void ARFrameUpdate(UnityARCamera camera)
public delegate void ARAnchorAdded(ARPlaneAnchor anchorData)
public delegate void ARAnchorUpdated(ARPlaneAnchor anchorData)
public delegate void ARAnchorRemoved(ARPlaneAnchor anchorData)
public delegate void ARSessionFailed(string error)
“/Assets/Plugins/iOS/UnityARKit/NativeInterface/AR*.cs” - these are the scripting API equivalents of data structures exposed by ARKit
“/Assets/Plugins/iOS/UnityARKit/Utility/UnityARAnchorManager.cs” - this is a utility that keeps track of the anchor updates from ARKit and can create corresponding Unity gameobjects for them (see GeneratePlanes.cs component on how to use it)
“/Assets/Plugins/iOS/UnityARKit/Editor/UnityARBuildPostprocessor.cs” - this is an editor script that runs at build time on iOS
ARKit useful components:
“/Assets/Plugins/iOS/UnityARKit/UnityARCameraManager.cs” - this component should be placed on a gameobject in the scene that references the camera that you want to control via ARKit, and it will position and rotate the camera as well as provide the correct projection matrix to it based on updates from ARKit. This component also has the code to initialize an ARKit session.
“/Assets/Plugins/iOS/UnityARKit/UnityARVideo.cs” - this component should be placed on the camera and grabs the textures needed for rendering the video, and sets it on the material needed for blitting to the backbuffer, and sets up the command buffer to do the actual blit
You should be able to build the UnityARKitScene.unity to iOS to get a taste of what ARKit is capable of. It demostrates all the basic functionality of the ARKit in this scene.
Please feel free to extend the plugin and send pull requests. You may also provide feedback if you would like improvements or want to suggest changes. Happy coding and have fun!