Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Thay vì tải một tệp .zip lớn chứa tất cả các tệp .unitypackage cho cả .NET 3.X và .NET 4.X, bạn có thể tải các gói riêng lẻ xuống từ trang web Google API cho Unity.
Trang web này cung cấp:
Các tệp .unitypackage .NET 4.X riêng lẻ để nhập dưới dạng gói Tài sản.
Các kho lưu trữ .tgz riêng lẻ cần nhập bằng Unity Package Manager.
Điều này đặc biệt hữu ích khi ứng dụng của bạn sử dụng một sản phẩm Firebase duy nhất, vì các tệp .unitypackage riêng lẻ chứa tất cả các phần phụ thuộc cần thiết và các tệp .tgz được liệt kê cùng với các tệp .tgz có liên quan mà chúng phụ thuộc vào.
Trang này cung cấp hướng dẫn liên quan đến Unity Package Manager, vì vậy, bạn nên tìm hiểu về công cụ này trong tài liệu của Unity.
Nhập các gói Firebase dưới dạng Tài sản
Khi nhập các sản phẩm Firebase từ tệp .unitypackage đã tải xuống từ trang web Google API cho Unity, hãy lưu ý những điều sau:
Nếu đang sử dụng nhiều sản phẩm Firebase trong dự án, bạn phải tải xuống và nâng cấp tất cả sản phẩm Firebase lên cùng một phiên bản.
Không kết hợp các phương thức nhập trong một dự án. Tức là không nhập các sản phẩm của Firebase bằng quy trình Gói tài sản và sử dụng quy trình Trình quản lý gói Unity.
Sau khi tải xuống, để nhập:
Trong dự án Unity đang mở, hãy chuyển đến Assets (Tài sản) > Import Package (Nhập gói) > Custom Package (Gói tuỳ chỉnh).
Trong cửa sổ Import Unity Package (Nhập gói Unity), hãy nhấp vào Import (Nhập).
Nhập các gói Firebase bằng Trình quản lý gói Unity
Phương thức này chỉ có trong phiên bản 2018.3 trở lên.
Nếu đang sử dụng nhiều sản phẩm Firebase trong dự án, bạn phải tải xuống và nâng cấp tất cả sản phẩm Firebase lên cùng một phiên bản.
Không kết hợp các phương thức nhập trong một dự án. Tức là không nhập các sản phẩm của Firebase bằng quy trình Gói tài sản và bằng quy trình Trình quản lý gói Unity.
Các phần phụ thuộc cho từng tệp .tgz của sản phẩm được liên kết cùng với các tệp .tgz riêng. Bạn phải tải xuống và nhập tệp .tgz sản phẩm và tệp .tgz phụ thuộc theo đúng thứ tự:
Trình quản lý phần phụ thuộc bên ngoài (com.google.external-dependency-manager)
Firebase Core (com.google.firebase.app)
Các sản phẩm của Firebase được dùng trong dự án của bạn. Nếu bạn sử dụng Realtime Database hoặc Cloud Storage, trước tiên hãy nhập Authentication (com.google.firebase.auth).
Sau khi tải xuống, hãy nhập các tệp .tgz vào dự án của bạn bằng một trong các phương thức sau:
Giao diện người dùng của Trình quản lý gói
Mở cửa sổ Package Manager (Trình quản lý gói) của Unity.
Nhấp vào biểu tượng + ở góc trên cùng bên trái của cửa sổ Trình quản lý gói rồi chọn Add package from tarball để mở trình duyệt tệp.
Chọn tệp lưu trữ tarball mà bạn muốn trong trình duyệt tệp.
Một số phiên bản cũ của Unity 2019 không hỗ trợ việc thêm trực tiếp tarball.
Trong trường hợp này, bạn sẽ cần phải:
Giải nén tệp .tgz.
Nhấp vào biểu tượng + ở góc trên cùng bên trái của cửa sổ Trình quản lý gói rồi chọn Add package from disk để mở trình duyệt tệp.
Chọn thư mục đã giải nén trong trình duyệt tệp.
manifest.json
Tạo một thư mục mới bên cạnh thư mục Packages của dự án rồi đặt tên là GooglePackages.
Đặt các tệp .tgz vào thư mục đó.
Sử dụng trình chỉnh sửa văn bản để mở Packages/manifest.json trong thư mục dự án Unity của bạn.
Thêm một mục cho mỗi gói bạn muốn nhập, ánh xạ tên gói đến vị trí trên đĩa. Hãy nhớ thêm file: vào đường dẫn tệp .tgz. Ví dụ: nếu bạn đang nhập com.google.firebase.storage và các phần phụ thuộc của nó, thì manifest.json sẽ có dạng như sau:
Di chuyển từ Unity Package Manager sang gói Tài sản
Trong một số trường hợp, bạn có thể muốn chuyển từ việc sử dụng Unity Package Manager để theo dõi các sản phẩm của Firebase sang nhập các sản phẩm trong thư mục Assets.
Nếu bạn không chắc chắn mình đang dùng phương thức nhập nào, hãy mở tệp Packages/manifest.json trong thư mục dự án Unity. Nếu tệp chứa các mục bắt đầu bằng com.google.firebase, thì dự án của bạn đã dùng Unity Package Manager để nhập.
Cách di chuyển sang Gói tài sản:
Ghi lại các phiên bản gói Firebase hiện tại trong dự án của bạn rồi xoá chúng.
Trong trình đơn Window (Cửa sổ), hãy chọn Package Manager (Trình quản lý gói). Trong cửa sổ Package Manager (Trình quản lý gói), hãy nhớ chọn "Packages: In Project" (Gói: Trong dự án).
Lưu ý các phiên bản của gói Firebase đã nhập.
Nhấp vào từng tên gói rồi nhấp vào Xoá. Hãy nhớ xoá gói Trình quản lý phần phụ thuộc bên ngoài (.com.google.external-dependency-manager) cũng như các gói Firebase.
Tải xuống và nhập tệp .unitypackage thay thế. Bạn có hai tuỳ chọn:
Nếu có thể nâng cấp lên phiên bản mới nhất của từng gói, hãy tải tệp zip Firebase Unity SDK xuống rồi nhập như mô tả trong phần Thêm Firebase vào dự án Unity.
Nếu cần giữ lại các phiên bản .unitypackage hiện tại, bạn có thể tải xuống và nhập các gói riêng lẻ như mô tả ở trên trên trang này.
Di chuyển từ gói Tài sản sang Unity Package Manager
Trong một số trường hợp, bạn có thể muốn chuyển từ việc nhập sản phẩm trong thư mục Assets sang nhập và theo dõi sản phẩm bằng Unity Package Manager.
Nếu bạn không chắc chắn mình đang dùng phương thức nhập nào, hãy mở tệp Packages/manifest.json trong thư mục dự án Unity. Nếu tệp chứa các mục bắt đầu bằng com.google.firebase, thì dự án của bạn đã sử dụng Unity Package Manager để nhập.
Cách di chuyển sang Unity Package Manager:
Đảm bảo rằng bạn đã xoá tất cả các gói Firebase và gói Trình quản lý phần phụ thuộc bên ngoài khỏi thư mục Assets bằng một trong hai phương pháp sau.
Giao diện người dùng EDM4U
Trong dự án Unity đang mở, hãy chuyển đến Assets > External Dependency Manager > Version Handler > Uninstall Managed Packages (Tài sản > Trình quản lý phần phụ thuộc bên ngoài > Trình xử lý phiên bản > Gỡ cài đặt các gói được quản lý).
Chọn tất cả các gói Firebase và Trình quản lý phần phụ thuộc bên ngoài.
Nhấp vào Gỡ cài đặt gói đã chọn.
Xoá theo cách thủ công
Dùng các công cụ hệ thống tệp để xoá các thư mục sau theo cách thủ công:
Assets/Editor Default Resources/Firebase
Assets/ExternalDependencyManager
Assets/Firebase
Assets/Parse
Assets/Plugins/iOS/Firebase
Nhập các gói bằng Trình quản lý gói Unity, như mô tả ở trên trên trang này.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-09-03 UTC."],[],[],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."]]