其他 Unity 安装选项
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
您可以从 Unity 版 Google API 网站中下载各个软件包,而不是下载一个包含适用于 .NET 3.X 和 .NET 4.X 的所有 .unitypackage
文件的大型 .zip
文件。
该网站提供:
- 用于作为资源包导入的各个独立的 .NET 4.X
.unitypackage
文件。
- 使用 Unity Package Manager 导入的各个独立的
.tgz
归档。
如果您的应用使用单个 Firebase 产品,这一点尤为实用,因为各个独立的 .unitypackage
文件包含所有必需的依赖项,且 .tgz
文件会与它们所依赖的相关 .tgz
文件一起列出。
本页面提供有关 Unity Package Manager 的说明,建议您从 Unity 项目文档了解该工具。
将 Firebase 软件包作为资源导入
导入从 Unity 版 Google API 网站下载的 .unitypackage
文件中的 Firebase 产品时,请注意以下几点:
下载后,请按以下步骤导入:
在您打开的 Unity 项目中,依次转到 Assets(资源)> Import Package(导入资源包)> Custom Package(自定义资源包)。
在“Import Unity Package”窗口中,点击 Import。
使用 Unity Package Manager 导入 Firebase 软件包
导入从 Unity 版 Google API 归档中下载的 .tgz
文件中的 Firebase 产品时,请注意以下几点:
仅 2018.3 及以上版本支持使用此方法。
如果您在项目中使用多个 Firebase 产品,则必须下载所有这些 Firebase 产品并将其升级到同一版本。
请勿在一个项目中混用多种导入方法。也就是说,如果使用资源包工作流导入 Firebase 产品,请勿同时使用 Unity Package Manager 工作流。
每个产品 .tgz
文件的依赖项与其自己的 .tgz
文件相关联。您必须按正确的顺序下载并导入产品 .tgz
文件和依赖项 .tgz
文件:
- External Dependency Manager (
com.google.external-dependency-manager
)
- Firebase 核心 (
com.google.firebase.app
)
- 您的项目中使用的 Firebase 产品。如果您使用 Realtime Database 或 Cloud Storage,请先导入 Authentication (
com.google.firebase.auth
)。
下载后,使用以下任一方法将 .tgz
文件导入项目中:
软件包管理器界面
- 打开 Unity 的软件包管理器窗口。
- 点击软件包管理器窗口左上角的
+
图标,然后选择 Add package from tarball
以打开文件浏览器。
- 在文件浏览器中选择所需的 tar 压缩文件。
某些旧版本的 Unity 2019 不支持直接添加 tar 压缩文件。在这种情况下,您需要执行以下操作:
- 解压
.tgz
文件。
- 点击软件包管理器窗口左上角的
+
图标,然后选择 Add package from disk
以打开文件浏览器。
- 在文件浏览器中选择已解压缩的文件夹。
manifest.json
- 在项目的
Packages
文件夹旁边创建一个新文件夹,并将其命名为 GooglePackages
。
- 将
.tgz
文件放在该文件夹中。
- 使用文本编辑器打开 Unity 项目文件夹下的
Packages/manifest.json
。
为要导入的每个软件包添加一个条目,使软件包名称与磁盘上的位置对应。请务必将 file:
附加到 .tgz
文件路径。例如,如果您要导入 com.google.firebase.storage
及其依赖项,则您的 manifest.json
将如下所示:
{
"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...
}
}
保存 manifest.json
文件。
Unity 重新获得焦点时,将会重新加载 manifest.json
并导入新添加的软件包。
某些旧版本的 Unity 不支持在 manifest.json
中使用 .tgz
文件。在这种情况下,您应该执行以下操作:
- 解压
.tgz
文件。
修改 manifest.json
以使用指向解压缩文件夹(而不是 .tgz
文件)的路径,如下所示:
{
"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...
}
}
从 Unity Package Manager 改为使用资源包
在某些情况下,您可能需要放弃使用 Unity Package Manager 跟踪 Firebase 产品,改为在 Assets
文件夹下导入产品。
如果您不确定自己使用的是哪种导入方法,请在 Unity 项目文件夹中打开文件 Packages/manifest.json
。如果该文件包含以 com.google.firebase
开头的条目,则表示您的项目是使用 Unity Package Manager 导入的。
如需改为使用资源包,请执行以下操作:
记下项目中的当前 Firebase 软件包版本并将其移除。
- 从 Window 菜单中选择 Package Manager。在“Package Manager”(软件包管理器)窗口中,确保已选中“Packages: In Project”(软件包:项目中)。
- 记下已导入的 Firebase 软件包的版本。
- 点击各个软件包名称,然后点击移除。请务必移除 External Dependency Manager 软件包 (
.com.google.external-dependency-manager
) 以及 Firebase 软件包。
下载并导入替换的 .unitypackage
文件。您可以采用以下两种方法:
- 如果您可以升级到各个软件包的最新版本,请下载 Firebase Unity SDK zip 文件,然后按照将 Firebase 添加到您的 Unity 项目中的说明导入。
- 如果您需要保留当前的
.unitypackage
版本,可以按照本页上文所述下载并导入各个软件包。
从资源包改为使用 Unity Package Manager
在某些情况下,您可能需要放弃从 Assets
文件夹下导入产品,改为使用 Unity Package Manager 导入和跟踪产品。
如果您不确定自己使用的是哪种导入方法,请在 Unity 项目文件夹中打开文件 Packages/manifest.json
。如果文件包含以 com.google.firebase
开头的条目,则表示您的项目已在使用 Unity Package Manager 进行导入。
如需改为使用 Unity Package Manager,请执行以下操作:
请使用以下任一方法从 Assets
文件夹中移除所有 Firebase 软件包和 External Dependency Manager 软件包。
EDM4U 界面
- 在您打开的 Unity 项目中,依次点击 Assets(资产)> External Dependency Manager > Version Handler(版本处理程序)> Uninstall Managed Packages(卸载管理的软件包)。
- 选择所有 Firebase 软件包和 External Dependency Manager。
- 点击 Uninstall Selected Package。
手动移除
使用文件系统工具,手动删除以下文件夹:
Assets/Editor Default Resources/Firebase
Assets/ExternalDependencyManager
Assets/Firebase
Assets/Parse
Assets/Plugins/iOS/Firebase
按照本页上文所述,使用 Unity Package Manager 导入软件包。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-13。
[null,null,["最后更新时间 (UTC):2025-08-13。"],[],[],null,["\u003cbr /\u003e\n\nRather than downloading a large `.zip` file containing all `.unitypackage`\nfiles for both .NET 3.X and .NET 4.X, you can download individual packages from\nthe [Google APIs for Unity site](https://developers.google.com/unity/packages).\n\nThe site provides:\n\n- Individual .NET 4.X `.unitypackage` files to import as Asset packages.\n- Individual `.tgz` archives to import using Unity Package Manager.\n\nThis is especially useful when your app uses a single Firebase product, since\nthe individual `.unitypackage` files contain all needed dependencies, and the\n`.tgz` files are listed alongside related `.tgz` files on which they depend.\n\nThis page provides instructions involving Unity Package Manager, so it's a good\nidea to learn about the tool [from the Unity documentation](https://docs.unity3d.com/Manual/Packages.html).\n| **Note:** If you still need to use .NET 3.x, download the entire Firebase SDK as described in [Add Firebase to your Unity project](/docs/unity/setup#add-sdks).\n\nImport Firebase packages as Assets\n\nWhen importing Firebase products from `.unitypackage` files downloaded from\n[Google APIs for Unity site](https://developers.google.com/unity/packages),\nkeep the following in mind:\n\n- If you are using multiple Firebase products in your project, you must download\n and upgrade all Firebase products to the same version.\n\n- Do not mix import methods in one project. That is, do not import\n Firebase products with the Asset package flow and using the Unity Package\n Manager flow.\n\nAfter downloading, to import:\n\n1. In your open Unity project, navigate to **Assets** \\\u003e **Import Package** \\\u003e\n **Custom Package**.\n\n2. In the *Import Unity Package* window, click **Import**.\n\nImport Firebase packages using Unity Package Manager\n\nWhen importing Firebase products from `.tgz` files downloaded from the [Google APIs for Unity archive](https://developers.google.com/unity/archive), keep the following in mind:\n\n- This method is only available in 2018.3+.\n\n- If you are using multiple Firebase products in your project, you must download\n and upgrade all Firebase products to the same version.\n\n- Do not mix import methods in one project. That is, do not import\n Firebase products with the Asset package flow and with the Unity Package Manager\n flow.\n\n- Dependencies for each product `.tgz` file are linked alongside in their own\n `.tgz` files. You must download and import the product `.tgz` file and\n dependency `.tgz` files, in the correct order:\n\n 1. External Dependency Manager (`com.google.external-dependency-manager`)\n 2. Firebase Core (`com.google.firebase.app`)\n 3. Firebase products used in your project. If you use Realtime Database or Cloud Storage, import Authentication (`com.google.firebase.auth`) first.\n\nAfter downloading, import `.tgz` files into your project using one of the\nfollowing methods: \n\nPackage Manager UI\n\n1. Open Unity's Package Manager window.\n2. Click the `+` icon in the top-left corner of the Package Manager window and select `Add package from tarball` to open the file browser.\n3. Select the desired tarball in the file browser.\n\nSome older versions of Unity 2019 do not support adding tarballs directly.\nIn this case, you will need to:\n\n1. Unzip the `.tgz` file.\n2. Click the `+` icon in the top-left corner of the Package Manager window and select `Add package from disk` to open the file browser.\n3. Select the extracted folder in the file browser.\n\nmanifest.json\n\n1. Create a new folder next to your project's `Packages` folder and name it `GooglePackages`.\n2. Place the `.tgz` files into that folder.\n3. Use a text editor to open `Packages/manifest.json` under your Unity project folder.\n4. Add an entry for each package you want to import, mapping the package name\n to the location on disk. Be sure to append `file:` to the `.tgz` file path. For\n example, if you were importing `com.google.firebase.storage` and its\n dependency's, your `manifest.json` would look like this:\n\n {\n \"dependencies\": {\n \"com.google.external-dependency-manager\": \"file:../GooglePackages/com.google.external-dependency-manager-1.2.164.tgz\",\n \"com.google.firebase.app\": \"file:../GooglePackages/com.google.firebase.app-7.1.0.tgz\",\n \"com.google.firebase.auth\": \"file:../GooglePackages/com.google.firebase.auth-7.1.0.tgz\",\n \"com.google.firebase.storage\": \"file:../GooglePackages/com.google.firebase.storage-7.1.0.tgz\",\n // com.unity package entries...\n }\n }\n\n5. Save the `manifest.json` file.\n\n6. When Unity regains focus it will reload the `manifest.json` and import the\n newly-added packages.\n\nSome older versions of Unity do not support `.tgz` files in the `manifest.json`.\nIn this case, you should:\n\n1. Unzip the `.tgz` file.\n2. Edit your `manifest.json` to use the path to the extracted folder, instead\n of the `.tgz` file, like so:\n\n {\n \"dependencies\": {\n \"com.google.external-dependency-manager\": \"file:../GooglePackages/com.google.external-dependency-manager-1.2.164\",\n \"com.google.firebase.app\": \"file:../GooglePackages/com.google.firebase.app-7.1.0\",\n \"com.google.firebase.auth\": \"file:../GooglePackages/com.google.firebase.auth-7.1.0\",\n \"com.google.firebase.storage\": \"file:../GooglePackages/com.google.firebase.storage-7.1.0\",\n // com.unity package entries...\n }\n }\n\nMigrate from Unity Package Manager to Asset packages\n\nIn some cases, you might want to switch from using Unity Package Manager to\ntrack Firebase products, to importing products under the `Assets` folder.\n\nIf you're not sure which import method you're using, in your Unity project\nfolder, open the file `Packages/manifest.json`. If the file contains entries\nstarting with `com.google.firebase`, your project used Unity Package Manager for\nimport.\n\nTo migrate to Asset packages:\n\n1. Note current Firebase package versions in your project and remove them.\n\n 1. From the **Window** menu, select **Package Manager** . In the *Package\n Manager* window, make sure \"Packages: In Project\" is selected.\n 2. Note the versions of imported Firebase packages.\n 3. Click on each package name, then click **Remove** . Be sure to remove the External Dependency Manager package (`.com.google.external-dependency-manager`) as well as Firebase packages.\n2. Download and import replacement `.unitypackage` files. You have two options:\n\n - If you can upgrade to the latest version of each package, download the Firebase Unity SDK zip file and import as described in [Add Firebase to\n your Unity project](/docs/unity/setup#add-sdks).\n - If you need to preserve current `.unitypackage` versions, you can download and import individual packages as described [above](#alternative_individual_unitypackages) on this page.\n\nMigrate from Asset packages to Unity Package Manager\n\nIn some cases, you might want to switch from importing products under the\n`Assets` folder to importing and tracking products with Unity Package Manager.\n\nIf you're not sure which import method you're using, in your Unity project\nfolder, open the file `Packages/manifest.json`. If the file contains entries\nstarting with `com.google.firebase` your project is already using Unity Package\nManager for import.\n\nTo migrate to Unity Package Manager:\n\n1. Make sure all Firebase packages and the External Dependency Manager package\n are removed from the `Assets` folder, using either of the following methods.\n\n EDM4U UI\n\n\n 1. In your open Unity project, navigate to **Assets \\\u003e External\n Dependency Manager \\\u003e Version Handler \\\u003e Uninstall Managed\n Packages**.\n 2. Select all Firebase packages and External Dependency Manager.\n 3. Click **Uninstall Selected Package**.\n\n \u003cbr /\u003e\n\n Manual removal\n\n Using file system tools, manually delete the following folders:\n - `Assets/Editor Default Resources/Firebase`\n - `Assets/ExternalDependencyManager`\n - `Assets/Firebase`\n - `Assets/Parse`\n - `Assets/Plugins/iOS/Firebase`\n2. Import packages using Unity Package Manager, as described [above](#alternative_unity_package_manager)\n on this page."]]