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.
- Have a
- 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.
- Have a
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
Open the package manager settings by selecting the Unity menu option Edit > Project Settings > Package Manager.
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
Open the package manager menu by selecting the Unity menu option Window > Package Manager.
Set the manager scope drop-down to select My Registries.
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
- Create a new folder next to your project's
Packages
folder and name itGooglePackages
. - Place the
.tgz
files into that folder. - Use a text editor to open
Packages/manifest.json
under your Unity project folder. 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 appendfile:
to the.tgz
file path. For example, if you were installingcom.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... } }
Save the manifest.json file.
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:
- Uncompress the
.tgz
files. - Place the extracted folder in the
GooglePackages
folder. 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
- Open Unity's Package Manager window.
Click the
+
icon in the top-left corner of the Package Manager window and selectAdd package from tarball
to open the file browser.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:
- Uncompress the
.tgz
file. Click the
+
icon in the top-left corner of the Package Manager window and selectAdd package from disk
to open the file browser.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:
- External Dependency Manager (
com.google.external-dependency-manager
) - Firebase Core (
com.google.firebase.app
) - Firebase Auth (
com.google.firebase.auth
) - 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
- Open Unity's Package Manager window.
Select
In Project
in the dropdown on the upper left.Type
com.google
into the search bar to filter for Google packages.Click on each package name then click
Remove
.
manifest.json
- Use a text editor to open
Packages/manifest.json
under your Unity project folder. - Check if there are any packages from Google under "dependencies". The package name should start with "com.google", for instance "com.google.firebase.app".
- Delete those lines and save the json file.
- 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:
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 underAssets
.
Install packages using Unity Package Manager, as described above.
Product-specific Migration Instructions
See here for Firebase instructions.