Skip to content

Modifying artoolkitX for Unity

Philip Lamb edited this page Sep 11, 2023 · 1 revision

Developer setup

Most users will be happy with using a published version of the artoolkitX for Unity plugins, however if you are a developer who wishes to modify artoolkitX for Unity (perhaps you wish to alter how it works, or perhaps you wish to contribute to the open-source project), a slightly different development setup is required.

Rather than checking out the OpenUPM package or using the upm branch of the GitHub project repository, check out the master branch of the GitHub repository. The root of the repo is configured as a Unity project, however prior to opening it in Unity, one additional essential extra step is required: you'll need to fetch (or build) the artoolkitX native plugins for the platform you're developing for.

Whereas the artoolkitX for Unity package published on OpenUPM or via the upm branch of the arunityx GitHub repository include pre-compiled native plugins of artoolkitX for each platform:

Plugins/Android/libs/arm64-v8a/libARX.so
Plugins/Android/libs/armeabi-v7a/libARX.so
Plugins/Android/libs/x86/libARX.so
Plugins/Android/libs/x86_6/libARX.so
Plugins/iOS/libARX.a 
Plugins/ARX.bundle
Plugins/x86_64/ARX.dll

in the development repository, these are not included and need to be fetched (or built locally).

You can fetch the same version of artoolkitX, or a different one, or build a locally checked-out git version using the build.sh script. This should be run from a bash shell. On mac OS, run from Terminal, or on Windows, use either git-bash (available as part of the Git for Windows distribution) or a WSL shell:

cd dev/
./build.sh PLATFORMS

where PLATFORMS is one or more of: android, ios, macos, or windows. The script will fetch the binary release packages for the named platforms based on the version number in the text file artoolkit-version.txt (so if you wish to target a different release build of artoolkitX, you can simply edit the file artoolkitx-version).

Note that it is not possible to unpack the macos or ios packages on a Windows system.

Finally, open the root of the checked-out repository in the Unity Editor (via Unity Hub).

Using a local build of the native plugins

If you wish to modify the native artoolkitX code (which is packaged in the native plugin(s)), then rather than fetching prebuilt native plugins (as above), you'll need to do a local artoolkitX build. Note that this comes with additional requirements, as per the development instructions for artoolkitX.

To use a local build, use the same build.sh from the dev folder as above, but check out artoolkitx as a git submodule into the dev/artoolkitx directory first:

cd dev/
git submodule init
git submodule update

then add the --dev command-line switch to build.sh:

./build.sh --dev PLATFORMS

Using a debug build.

If you wish to use a debug build and/or do debug logging, you'll need to use a local build, but add the --debug switch:

./build.sh --dev --debug PLATFORMS

Debug logging is only available in a debug build, and with the log level set to AR_LOG_LEVEL_DEBUG:

Unity Editor view of ARXController component, showing the Log level set to AR_LOG_LEVEL_DEBUG