Unity: Migrate to the Unity Package Manager (Beta)

Prev Next

The Usercentrics Unity SDK is published both as a Unity Package Manager (UPM) package and as the .unitypackage you may already be using. This page covers every route between them, in both directions.

 BETA  Unity Package Manager support

Package Manager support is a Beta feature, first available in 2.36.0. Validate it in your project before releasing to production. If you run into a problem, contact Usercentrics support and include your Unity version, the package you installed (com.usercentrics.sdk or com.usercentrics.sdk.static) and its version.

The .unitypackage is unchanged and ships with every release.

You do not have to migrate

The .unitypackage is not deprecated and ships with every release. Migrate if you want Package Manager to handle versioning and updates for you.

Asset GUIDs are identical between the two install methods, so your scenes, prefabs and assembly definitions keep working either way.

What ships

Four artifacts per release, all built from the same sources.

Channel

Artifact

iOS linkage

Package Manager (npm registry)  BETA 

com.usercentrics.sdk

Dynamic frameworks

Package Manager (npm registry)  BETA 

com.usercentrics.sdk.static

Static frameworks

Bitbucket Downloads

Usercentrics-2.X.X.unitypackage

Dynamic frameworks

Bitbucket Downloads

Usercentrics-2.X.X-static.unitypackage

Static frameworks

The practical differences:

.unitypackage

UPM package

SDK files

Assets/Usercentrics/

Packages/com.usercentrics.sdk/

Editable by you

Yes

No, the package is immutable

External Dependency Manager

Bundled

You install it yourself

Updating

Import a new .unitypackage

Change one line in manifest.json

Before you start

Prerequisites

  • Commit or back up your project. Migrating deletes a folder.

  • Install the External Dependency Manager (EDM4U). The UPM packages do not bundle it.

  • Version 2.36.0 or newer. That is the first release published as a UPM package; earlier versions are only available as .unitypackage.

  • Unity 2018.4 or newer for com.usercentrics.sdk. The static package needs Unity 2019.3 or newer for iOS builds.

  • Unity 2018.4 has no scoped registries — use the tarball route below.

Install exactly one Usercentrics SDK

Never the .unitypackage together with a UPM package, and never both UPM packages. They share asset GUIDs, so Unity silently ignores one of them — or both.

From the .unitypackage to the UPM package

The order of these steps matters: remove first, then add.

  1. Delete the folder Assets/Usercentrics and its .meta file.

    Keep Assets/ExternalDependencyManager

    It looks like part of the SDK, but the UPM package does not replace it. If you delete it, your build still succeeds and your app fails at startup with a ClassNotFoundException for com.usercentrics.sdk.unity.UsercentricsUnity.

    Keep Assets/Plugins as well. The SDK never installs anything there — those are your own files, including any Gradle templates you have customised.

  2. Add the scoped registry and the dependency to Packages/manifest.json:

    {
      "scopedRegistries": [
        {
          "name": "Usercentrics",
          "url": "https://registry.npmjs.org",
          "scopes": [ "com.usercentrics" ]
        }
      ],
      "dependencies": {
        "com.usercentrics.sdk": "2.X.X"
      }
    }

    For static linkage on iOS use com.usercentrics.sdk.static instead. One or the other, never both.

  3. Let Unity import the package. The Console should be clean. If you see "Usercentrics is installed more than once", step 1 did not complete.

  4. Resolve the native dependencies: Assets - External Dependency Manager - Android Resolver - Force Resolve.

    The first Force Resolve can fail

    On a project that has no Assets/Plugins/Android folder yet, the first Force Resolve fails with "Unable to copy 'mainTemplate.gradle'" and resolves nothing. This is an EDM4U behaviour, not a Usercentrics one. The failed attempt creates the folder, so run Force Resolve a second time.

  5. Build and run, then work through Checking the migration worked.

Installing without a registry, or on Unity 2018.4

Scoped registries start at Unity 2019.1, and some projects cannot reach a registry at all. Install from the tarball instead.

  1. Download the tarball from the npm registry, replacing 2.X.X with the version you want (2.36.0 or newer):

    https://registry.npmjs.org/com.usercentrics.sdk/-/com.usercentrics.sdk-2.X.X.tgz
    https://registry.npmjs.org/com.usercentrics.sdk.static/-/com.usercentrics.sdk.static-2.X.X.tgz

    With Node.js installed, npm pack com.usercentrics.sdk@2.X.X downloads the same file.

  2. Put it inside your project, for example in LocalPackages/.

  3. Reference it by path in Packages/manifest.json:

    "dependencies": {
      "com.usercentrics.sdk": "file:../LocalPackages/com.usercentrics.sdk-2.X.X.tgz"
    }

    For the static package, use com.usercentrics.sdk.static as the dependency name and its tarball's filename.

Everything else is identical. Updating means downloading a new tarball and changing the filename.

Switching between the standard and the static package

The two packages differ only in how the iOS frameworks are linked; Android is identical. They share every asset GUID, so switching keeps your scenes and prefabs intact.

Switch by replacing the dependency, never by adding the second one: remove the current package, let Unity recompile, then add the other one.

Having both installed is the worst case

Both copies claim the same asset GUIDs, Unity ignores both, and Unity.Usercentrics.dll is never built — so every script of yours that calls the SDK stops compiling. It looks like your own code broke.

Export the iOS project again after switching rather than reusing a previous export: the old linkage is still recorded in the exported Podfile and Podfile.lock.

Updating to a newer version

Change the version in Packages/manifest.json, or use Window - Package Manager. Unity drops the old version from its cache; there is nothing to clean up.

Going back to the .unitypackage

The order matters here too, and in the opposite direction from what you might expect.

  1. Remove the dependency from Packages/manifest.json (or remove the package in Window - Package Manager) and let Unity recompile.

  2. Then import the .unitypackage.

Importing in the wrong order does nothing at all

Importing the .unitypackage while the UPM package is still installed imports nothing. No files appear, no error is shown, and the import dialog closes as if it had worked. The package already owns those asset GUIDs, so Unity discards every incoming file.

If something looks wrong

The failures in this area are quiet. These are the ones worth recognising.

"Usercentrics is installed more than once"

You have two installs. Unity does not fail the import; it silently ignores one of them.

With the .unitypackage and a UPM package, the Assets/Usercentrics copy wins and the package is ignored — so you are still running the old code while believing you migrated. Delete Assets/Usercentrics and restart the editor.

With both UPM packages, neither wins: the SDK is not compiled into your project at all. Remove one of them and restart the editor.

The message appears once per editor session. If you install a second copy while the editor is open, restart it to see the message again.

The build succeeds but the app crashes at startup

On Android, a ClassNotFoundException for com.usercentrics.sdk.unity.UsercentricsUnity means the native dependencies were never resolved — almost always because Assets/ExternalDependencyManager was deleted during the migration, or because Force Resolve has not been run.

The build log carries a warning naming the missing resolver (Google.JarResolver or Google.IOSResolver).

The GameObject carrying the Usercentrics component must keep the name Usercentrics. The native SDK delivers its callbacks to a GameObject of that name, so a renamed instance initialises natively and then goes quiet: IsInitialized stays false and no error is written anywhere.

"Package installed without a signature"

Informational. Unity shows this for any package that comes from a registry other than its own.

Version control, CI, and your own file references

Migrating moves the SDK out of Assets/, which changes what your repository holds. This is the part that outlives the migration itself.

Version control

  • Commit Packages/manifest.json and Packages/packages-lock.json. The lock file pins the exact version your colleagues and your CI resolve; without it, a clean checkout can quietly pick up a different one.

  • Do not commit the package itself. Unity restores it into Library/PackageCache, which is not under version control, so a clean checkout of a registry install needs network access when the project is opened. A tarball install does not, which is one reason CI builds often prefer it.

  • Delete Assets/Usercentrics from the repository in the same commit that adds the dependency, so that no branch ever contains both.

Paths in your own files

Anything of yours that names the SDK by path has to be repointed, because Assets/Usercentrics is gone:

Packages/com.usercentrics.sdk/...     instead of     Assets/Usercentrics/...

The usual places are your own link.xml, assembly definition references, editor or build scripts that load the prefab by path, and .gitignore entries. References by GUID need no change at all — scenes, prefabs and assembly definitions refer to assets by GUID, and those are identical between the two install methods.

A UPM package is immutable

Unity restores the package from its cache, so any edit to a file under Packages/com.usercentrics.sdk/ is lost on the next resolve, without a warning.

If you had patched the SDK inside Assets/Usercentrics, move that change out of the SDK before you migrate — into your own script, your own Gradle template, or a build callback. If it cannot be moved out, stay on the .unitypackage: it remains supported precisely because it stays editable.

Checking the migration worked

  1. The Console is clean after the import, with no "installed more than once" error.

  2. The package appears in Window - Package Manager under the Usercentrics registry, at the version you asked for.

  3. Your scenes still reference the prefab: select a Usercentrics object in a scene and confirm it is still a prefab instance with no missing scripts.

  4. After Force Resolve, Assets/Plugins/Android/mainTemplate.gradle contains a line like

    implementation 'com.usercentrics.sdk:usercentrics-ui:[2.X.X]'

    with a trailing comment pointing at Packages/com.usercentrics.sdk/Editor/UsercentricsDependencies.xml. If that comment still points at Assets/Usercentrics, the old copy is still in use and the migration is only half done.

  5. Build and run on a device or emulator, and confirm the first layer appears.

Migration complete

Continue to Initialize the App SDK. 🚀