Adding a dependency to the project manifest
Follow these steps to add a dependency to your project by modifying the project manifest file:
Locate the project manifest file (
manifest.json
) under your project'sPackages
folder.Open the
manifest.json
file in a text editor or in an Integrated Development Environment (IDE), such as Visual Studio.Inside the
dependencies
object, the default packages appear at the top, followed by the built-in packages. Default packages are pre-installed in the Unity Editor, and most built-in packages begin with"com.unity.modules"
:{ "dependencies": { "com.unity.collab-proxy": "1.3.8", "com.unity.ide.rider": "2.0.5", "com.unity.ide.visualstudio": "2.0.2", "com.unity.ide.vscode": "1.2.1", "com.unity.test-framework": "1.1.14", "com.unity.textmeshpro": "3.0.0-preview.1", "com.unity.timeline": "1.4.0", "com.unity.ugui": "1.0.0", "com.unity.modules.ai": "1.0.0", ... "com.unity.modules.xr": "1.0.0" } }
Add a line to the
dependencies
object, using the package's name as the key and the version number as the value. Using a version number means the Package Manager installs the package from the registry. However, you can also specify:- A path to a local folder to install a package from your computer (for example, if you cloned a remote repository locally)
- A path to a local tarball file to install a package from a downloaded tarball
A valid Git URL to install a package directly from a Git repository
Note: You can only install one version of a package in a project. If you try to add two lines containing the same key, the Package Manager logs an error in the Editor console.
Make sure that you use valid JSON syntax, such that:
- Every line inside the
dependencies
object ends in a comma, except the final line which can't end in a comma. - Both the key and the value are strings (that is, wrap them inside quotation marks).
Separate the key and value pair with a colon. This indicates their key/value relationship in JSON.
Note: If you make a mistake and enter invalid JSON, the Package Manager logs an error to the console, notifying you which line contains the error.
- Every line inside the
Save your changes to the file and open the Unity Editor.
Note: Even if the Editor is already open, the Package Manager doesn't start resolving the package you added to the manifest until it regains focus.
Manifest example
This example shows the four different ways you can specify where you want the Package Manager to retrieve the package source from:
{
"dependencies": {
"com.example.my-package": "0.1.2-preview.3",
"com.example.my-local-package": "file:../../my_package_folder_containing_a_package_manifest",
"com.example.my-local-tarball": "file:/Users/my_username/Downloads/my_package_tarball.tgz",
"com.example.my-git-package": "git+https://example.com/my_repository/my_package.git#v1.2.3"
}
}
Package source: | Value: |
---|---|
The Unity package registry | 0.1.2-preview.3 |
A folder on your computer (for example, if you cloned a remote repository locally) | file:../../my_package_folder_containing_a_package_manifest |
A tarball on your computer (for example, if you downloaded a tarball) | file:/Users/my_username/Downloads/my_package_tarball.tgz |
A remote Git repository | git+https://example.com/my_repository/my_package.git#v1.2.3 |