Install Google packages for Unity

Google packages for Unity are distributed in two different formats:

  • Asset packages:
    • Have a .unitypackage extension.
    • Install to your project's Assets directory.
    • Can be imported in Unity 5 and up.
    • Generally include dependent packages.
  • Unity Package Manager (UPM) packages:
    • Have a .tgz extension.
    • Install to your project's Packages directory.
    • Can be imported in Unity 2018.4 and up.
    • Reference dependent packages which need to be installed separately.

The Packages page contains the latest .unitypackage files for all available packages, and .tgz files for some of the packages.

The Archive page contains .unitypackage and .tgz files for all package versions.

Below you can find instructions on how to install both types of packages, along with migration instructions to transition from on type to the other.

Once you're familiar with these installation options, be sure to refer to additional product-specific instructions for Firebase.

Importing packages using OpenUPM

You can add external packages to your Unity project using the OpenUPM registry. OpenUPM hosts many useful plugins and SDKs, such as the Google Play Integrity plugin, which helps protect your app from fraud and abuse.

Here's how to add, for example, the Google Play Integrity plugin using OpenUPM.

OpenUPM-CLI

If you have the OpenUPM CLI installed you can install the OpenUPM registry with the following command:

openupm add com.google.play.integrity

OpenUPM

  1. Open the package manager settings by selecting the Unity menu option Edit > Project Settings > Package Manager.

  2. Add OpenUPM as a scoped registry to the Package Manager window:

    Name: package.openupm.com
    URL: https://package.openupm.com
    Scopes: com.google.external-dependency-manager
     com.google.play.common
     com.google.play.core
     com.google.play.integrity
    
  3. Open the package manager menu by selecting the Unity menu option Window > Package Manager.

  4. Set the manager scope drop-down to select My Registries.

  5. Select the Google Play Integrity plugin for Unity package from the package list and press Install.

Importing Asset packages with .unitypackage files

Import the .unitypackage file by selecting the Unity menu option Assets > Import package > Custom Package and importing all items. This adds the package contents to your project under the Assets directory.

Importing UPM packages with .tgz files (2018.4+)

Import .tgz files into your project using one of the following methods:

manifest.json

  1. Create a new folder next to your project's Packages folder and name it GooglePackages.
  2. Place the .tgz files into that folder.
  3. Use a text editor to open Packages/manifest.json under your Unity project folder.
  4. Add an entry for each package you want to install, mapping the package name to the location on disk, relative to the Packages/manifest.json file. Be sure to append file: to the .tgz file path. For example, if you were installing com.google.firebase.storage and its dependencies, your manifest.json would look like this:

    {
      "dependencies": {
        "com.google.external-dependency-manager": "file:../GooglePackages/com.google.external-dependency-manager-1.2.164.tgz",
        "com.google.firebase.app": "file:../GooglePackages/com.google.firebase.app-7.1.0.tgz",
        "com.google.firebase.auth": "file:../GooglePackages/com.google.firebase.auth-7.1.0.tgz",
        "com.google.firebase.storage": "file:../GooglePackages/com.google.firebase.storage-7.1.0.tgz",
        // com.unity package entries...
      }
    }
    
  5. Save the manifest.json file.

  6. When Unity regains focus it will reload the manifest.json and import the newly added packages.

Some older versions of Unity do not support .tgz files in the manifest.json. In this case, you should:

  1. Uncompress the .tgz files.
  2. Place the extracted folder in the GooglePackages folder.
  3. Edit your manifest.json to use the path to the extracted folder, instead of the .tgz file, like so:

    {
      "dependencies": {
        "com.google.external-dependency-manager": "file:../GooglePackages/com.google.external-dependency-manager-1.2.164",
        "com.google.firebase.app": "file:../GooglePackages/com.google.firebase.app-7.1.0",
        "com.google.firebase.auth": "file:../GooglePackages/com.google.firebase.auth-7.1.0",
        "com.google.firebase.storage": "file:../GooglePackages/com.google.firebase.storage-7.1.0",
        // com.unity package entries...
      }
    }
    

Package Manager UI

  1. Open Unity's Package Manager window.
  2. Click the + icon in the top-left corner of the Package Manager window and select Add package from tarball to open the file browser.

    Screenshot of Unity Package Manager Window with the

  3. Select the desired tarball in the file browser.

Some older versions of Unity do not support adding tarballs directly. In this case, you will need to:

  1. Uncompress the .tgz file.
  2. Click the + icon in the top-left corner of the Package Manager window and select Add package from disk to open the file browser.

    Screenshot of Unity Package Manager Window with the

  3. Select the extracted folder in the file browser.

Make sure to also import the .tgz files for the package's dependencies, which you can find listed on the archive page under the desired package's section.

For example, if you were installing com.google.firebase.storage, you would install these .tgz files in the following order:

  1. External Dependency Manager (com.google.external-dependency-manager)
  2. Firebase Core (com.google.firebase.app)
  3. Firebase Auth (com.google.firebase.auth)
  4. Firebase Storage (com.google.firebase.storage)

If you would prefer to add all the .tgz files at once, without worrying about the order, you can follow the instructions in the manifest.json tab.

Version control

If you're using version control software to manage your project files, we recommend adding the relevant .tgz files to version control. You can manually edit your project's manifest.json (see above instructions) and reference local .tgz files using relative paths.

If you're using git, we recommend Git Large File Storage (LFS) for managing large .tgz files.

Migrating from UPM packages to Asset packages

In some cases, you might want to switch from using Unity Package Manager to manage Google packages, to installing packages under the Assets folder.

Make sure all Google packages are removed from Unity Package Manager using either of the following methods:

Package Manager UI

  1. Open Unity's Package Manager window.
  2. Select In Project in the dropdown on the upper left.

    Screenshot of Unity Package Manager Window with the

  3. Type com.google into the search bar to filter for Google packages.

    Screenshot of Unity Package Manager Window with

  4. Click on each package name then click Remove.

manifest.json

  1. Use a text editor to open Packages/manifest.json under your Unity project folder.
  2. Check if there are any packages from Google under "dependencies". The package name should start with "com.google", for instance "com.google.firebase.app".
  3. Delete those lines and save the json file.
  4. When Unity regains focus, it will reload the manifest.json file and remove the deleted packages.

Once you have uninstalled those packages from Unity Package Manager, you can download and import replacement .unitypackage files from the archive page.

Migrating from Asset packages to UPM packages

In some cases, you might want to switch from installing products under the Assets tree to installing and tracking products with Unity Package Manager.

If you're not sure which installation method you're using, in the Unity UI, check whether the desired Google packages appears in the Project tab, under Assets.

To migrate to UPM packages:

  1. Make sure all Google package are removed from the Assets folder.

    • To uninstall Firebase packages follow these instructions.
    • To uninstall Play Plugins for Unity, delete the GooglePlayPlugins folder under Assets.
  2. Install packages using Unity Package Manager, as described above.

Product-specific Migration Instructions

See here for Firebase instructions.