Building and Using the File Driver Sample in Unity¶
The File Driver Sample demonstrates how to implement a driver which uses an external camera and external device tracking to feed Vuforia Engine camera frames and device poses, respectively. Import the Vuforia File Driver into Unity to play back video sequences on your device.
Prerequisites¶
The File Driver sample can be downloaded from the Developer Portal. The File Driver is configured to load an MP4 file that was recorded using the SessionRecorder API. The device tracking poses, which are embedded in the recording, are fed into Vuforia Engine along with camera frames from the video track.
The File Driver Sample includes two sets of example recordings: Use the Astronaut Image Target and sequence for Unity.
Or, use the Session Recorder API to create your own sequences as MP4 files, See the Session Recorder API and Recording and Playback for details.
Build the Driver¶
See the steps for building the File Driver sample in the README.md
file that is a part of the package. Make sure to build the library targeting your build platform in Unity.
See Using the File Driver Sample in Native for implementation steps using native IDEs such as Android Studio, Xcode, or Visual Studio.
Add the File Driver¶
After you have built the File Driver for your desired platform, the output library can be imported into Unity.
NOTE: This sample should be used together with a Session Recording MP4 file available in the device storage.
NOTE: Play mode in Unity does not load Vuforia Engine that is initialized from drivers. Instead, play back a Session Recording in the Unity Editor, see Recording and Playback.
-
Copy the compiled binaries from build/bin/[platform] to:
- Android:
Assets/Plugins/Android/
- UWP:
Assets/Plugins/WindowsStoreApps/[x64, ARM64]
-
iOS:
Assets/Plugins/iOS/
- Android:
-
Add the Session Recording to your Unity project. Copy your
MP4
recording into theAssets/StreamingAssets
folder. This ensures it's included in the application build and stored in device storage. -
In the VuforiaConfiguration window, enable Delayed initialization to allow for additional configuration and explicit initialization with the File Driver from your code. See Vuforia Engine Lifecycle for details.
-
Also, make sure to add a license key as the file driver will not work without it.
-
The driver library can then be set from any app level script, e.g., in a
Start()
method. After that, Vuforia Engine can be initialized:NOTE: TheuserData
can be replaced withIntPtr.Zero
if no user-defined data is needed.
NOTE: Make sure the File Driver framework is included as an embedded framework in your Xcode project when building to iOS platform. Refer to the step relating to linked libraries in the Building and Using the File Driver in Native in the iOS section.
Example script for initiating Vuforia from the file driver sequence. The image sequence should play in a loop instead of using the device camera.