Setup Guide Unity Plugin
There are only a few steps necessary to add the Wikitude Unity Plugin to your existing Unity project. This guide will explain them in detail. In general the steps are
- Import the Wikitude.unitypackage into your project
- Add the
WikitudeCamera
and one of theTracker
prefabs to the Unity scene hierarchy and configure their properties - Add a custom augmentation to the tracker as child GameObject to the
Trackable
- Export your project in order to fully integrate the Wikitude API in your Unity project
Import the Wikitude.unitypackage
The Wikitude Unity Plugin comes as a standard .unitypackage and can be imported through the usual Unity package import procedure.
In your Unity project, open the Assets
dropdown menu and choose Import Package -> Custom Package
.
Select the downloaded Wikitude.unitypackage in the presented open file browser and click open
. You should import all items that are part of the Wikitude.unitypackage.
Use the Wikitude Unity plugin
After the Wikitude.unitypackage was imported, its components and scripts can be used to define a custom augmented reality experience. The example section describes in more detail how those prefabs and scripts can be used to do so.
Export and Xcode Build Settings Changes
Once the application is setup in Unity and ready for testing on a real device, it needs to be exported as an Xcode project for iOS, Android Studio project for Android, or Visual Studio project for UWP. Alternatively, for Android you can build the .apk directly from Unity.
Export to Xcode
iOS developers need to open the exported project and manually do the steps listed below.
- Before exporting, make sure the
Target minimum iOS version
is set to 9.0 or later andCamera Usage Description
is set to an appropriate message in the Unity in Player Settings. These settings can also be done in the Xcode project, but setting them in Unity will ensure it they don't get overwritten when rebuilding your project. - After the Xcode project was exported, the
WikitudeSDK
framework has to be added as anEmbedded Binary
.
After these steps are done once, building with Append
or by pressing Cmd + B
will ensure that the settings are kept.
Export an .apk file
If you don't need an Android Studio project, building directly from Unity is the fastest way to run your app on an Android device.
- In Unity open
File | Build Settings...
- Make sure
Android
is the current build target. If not, selectAndroid
from the list and clickSwitch Platform
- Click
Build And Run
and choose where to save the .apk file. If you have an Android device connected, it will also install the app on it.
After this is done once, pressing Ctrl + B
(Windows) or Cmd + B
(Mac) will automatically create the .apk file and install it on your device, if it is connected.
64 bit support for Android
If you are using 2018.1 or later, you can enable experimental support for 64 bit builds on Android from Player Settings. To enable 64 bit support in the Wikitude binaries, copy the .aar files from the Libraries/Android/ARM64
folder inside the downloaded package into the Asssets/Plugins/Android
folder in the Unity project folder, replacing the existing ones there.
After that, simply build as usual.
Export to Android Studio
Unfortunately Unity projects exported as Android Studio projects do not work out of the box. Some manual work is required which we described in detail below:
- In Unity open
File | Build Settings...
, checkGoogle Android Project
and clickExport
- Open Android Studio and click
Import Project (Eclipse ADT, Gradle, etc.)
- Within the file selection dialog, navigate to the folder where you exported the project and select the folder named after your app
- In the next step choose a new, empty folder to import and click on
Next
- Finish importing by clicking
Finish
on the next screen - In Android Studio open
File | New | New Module ...
- Select
Import .JAR/.AAR Package
and click onNext
- For
File name:
navigate to the folder where you originally exported the project from Unity and then to the sub-folder named after your app - Select the file
wikitude-unity-bridge.aar
under libs and click onFinish
- Open the file
build.gradle (Module: YOUR_APP_NAME)
and add the linecompile project(':wikitude-unity-bridge')
under dependencies - The project is now running in Android Studio
Export to Visual Studio
When building for UWP, the following settings need to be enabled to make sure that the SDK is compatible with Unity.
From the Build Settings menu, please make sure that:
Target Device
is set toPC
Build Type
is set toD3D
Build and Run on
is set toLocal Machine
Additionally, from the Player Settings -> Other Settings:
Graphics APIs
is set toDirect3D11
Scripting Backend
is set toIL2CPP
And from Player Settings -> Publishing Settings:
Capabilities
hasInternetClient
andWebCam
enabled
At this point, the project can be exported to Visual Studio. Once the project is exported, you can build the project for x64
.
Unity Requirements and supported versions
- Unity 5.5.6 or higher
- Rendering engines
- OpenGL ES 2
- OpenGL ES 3.x
- Metal (iOS only)
- Direct3D 11 (UWP only)
- Because 64 bit libraries are not enabled by default on Android, performance on such devices might be lower than similar devices running iOS 64 bit. Please see the Android build section for more information on how to enable 64 bit support on Android.