Our Unity library allows you to use Zappar's best-in-class AR technology with content built using the Unity game engine.
You can use this library by importing the
zcv.unitypackage into your Unity project using Unity's
Assets > Import Package > Custom Package... menu entry.
The package includes:
- A set of prefabs to get you up and running quickly.
- A set of scripts that power those prefabs.
- Supporting materials and shaders.
- Supporting libraries for iOS, Android and WebGL build platforms.
- A new menu entry.
The Zappar menu entry (found along the top-level toolbar) has Zappar context specific components and utilities for ease of use.
The library is currently supported for Unity's iOS, Android and WebGL build platforms. You can switch between, and build, for each of these platforms without making any code or scene changes.
If you're building for iOS or Android, or you'd like to self-host a WebGL build on your own domain, you must register your app/site with ZapWorks. For more information see the Licensing article.
The Zappar plugin features full support for Play mode on macOS, and limited support on Windows. This means that you can preview your scenes using a webcam, right inside the Unity editor. With Play mode you can use Face and Image trackers, and preview your content without having to produce a full build. Since Instant World Tracking requires a device gyroscope sensor, it's not currently supported in Play mode.
Please read the considerations below for the different build platforms:
At this time, the Vulkan rendering API is not supported on Android. Please adjust your player settings on Android to use OpenGLES 2.0 or 3.0.
The library requires Android 6.0 (API version 23) or later so be sure to set the Minimum API level in your player settings to match.
As the library makes use of the camera, you must set Camera Usage Description in your player settings. This text is displayed to the user when the operating system shows the camera permissions prompt.
The default graphics API on iOS is Metal, however, there may be cases where you wish to use OpenGL. If this is the case, edit the line below within the
Assets/Plugins/iOS/zappar-unity.h file to prevent the Zappar library from linking against the Metal framework:
// Comment out the line below if you do not want to include support for Metal. #define ZAPPAR_METAL_SUPPORT
If you are building a Face Tracked experience (and / or if you're using the Face Mesh) for iOS you will need to add the
ZCV.bundle file into the root level of your generated Xcode project. This file can be found in
Assets/Zappar/ZCV.bundle. When including it into the project make sure that it is selected as a target of "Unity-iPhone" (or the relevant name of your application).
While Unity's WebGL support for mobile is currently 'experimental', we've found it's possible to build great AR experiences with Unity and deploy to the web.
Unity's built-in WebGL template does not render the player window in fullscreen by default. The Zappar library provides an alternative template that shows a simple loading bar while the Unity content is loading, and fills the full browser window. You can use this template by navigating to the Resolution and Presentation section in the Player Settings menu and selecting the Zappar template.
You can alter this template by editing the
Assets/WebGLTemplates/Zappar/index.html file, or alternatively by placing your own
index.html file inside a folder of your choice (itself inside the WebGLTemplates folder).
For more information on how to customise WebGL templates, please consult the Unity documentation.
Due to browser restrictions surrounding the use of the camera, you must use
HTTPS to view or preview your site, even if doing so locally from your computer. This means that Unity's Build and Run option will not work for previewing and testing your project.
You can use the ZapWorks command-line tool to serve your WebGL output folder over
HTTPS for access on your local computer:
You can also serve the folder for access by other devices on your local network:
zapworks serve --lan
Remember to run these commands within the folder that's generated by Unity when you build your project for WebGL - it should contain an
ZapWorks provides complete serving and hosting for your WebGL-based experiences, should you wish to use it. Find out more on our Publishing and Hosting article.
The Zappar Unity plugin contains the following assets:
Materials - UV.mat - uv-map.jpg Plugins - Android - ZCVAndroidRenderPlugin.h - libs/ - zappar.h - zcv.aar - iOS - libzcv.a - zappar.h - zappar-unity.h - zappar-unity.mm - zcv.cpp - zcv.jslib Resources - Prefabs - Zappar Camera.prefab - Zappar Face Tracker.prefab - Zappar Face Mesh.prefab - Zappar Image Tracker.prefab - Zappar Instant Tracker.prefab - ZCV.bundle Scripts - Editor - ZapparMenu.cs - Z.cs - ZapparCamera.cs - ZapparFaceTrackingTarget.cs - ZapparFaceMeshTarget.cs - ZapparImageTrackingTarget.cs - ZapparInstantTrackingTarget.cs - ZapparTrackingTarget.cs Shaders - CameraBackgroundShader.shader WebGLTemplates - Zappar - index.html
The UV image (Assets/Materials/uv-map.jpg) was created by Eugene Opperman and retrieved from Muse Creative. There are some additional files in the Resources directory that are necessary for building and running your application, but which you should not need to interact with.
While the prefabs included with the assets allow you to quickly build augmented reality experiences, the library also provides a rich API that you can use if you require greater control of the computer vision libraries. See the articles below for more information: