unity package manager что это
Unity’s Package Manager
A package is a container that stores various types of features or Assets, such as:
Packages deliver a wide range of enhancements to Unity through the Package Manager. In the Editor, you can access the Package Manager window through this menu: Window > Package Manager.
Note: The Package Manager also supports viewing any Asset packages you have already downloaded or imported from the Unity Asset Store. For more information, see Asset packages.
How Unity works with packages
When Unity opens a Project, the Unity Package Manager reads the Project manifest (1) to figure out what packages to load in the Project. Then it sends a request (2) to the registry server (3) for each package that appears as a dependency in the manifest. The registry server sends the requested information and data back to the Package Manager (4), which then installs those packages (5) in the Project. Each Project has its own manifest which lists the packages to load as “dependencies” of the Project.
How the Unity Package Manager installs packages
If you want to include a package in your Project, you must update the Project manifest to include it in the list of dependencies. If you want to, you can modify the Project manifest directly, but it is safer and easier to let the Package Manager do that. For more information on using the user interface, see the documentation for the Package Manager window.
How to use the Package Manager
The Package Manager uses three interfaces to communicate with users, manifests, and registries:
Unity’s Package Manager
A package is a container that stores various types of features or assets, such as:
Packages deliver a wide range of enhancements to Unity through the Package Manager. In the Editor, you can access the Package Manager window through this menu: Window > Package Manager.
How Unity works with packages
When Unity opens a Project, the Unity Package Manager reads the Project manifest Each Unity project has a project manifest, which acts as an entry point for the Package Manager. This file must be available in the
/Packages directory. The Package Manager uses it to configure many things, including a list of dependencies for that project, as well as any package repository to query for packages. More info
See in Glossary (1) to figure out what packages to load in the Project. Then it sends a request (2) to the package registry server (3) for each package that appears as a dependency
See in Glossary in the manifest. The package registry then sends the requested information and data back to the Package Manager (4), which then installs those packages (5) in the Project. Each Project has its own manifest which lists the packages to load as “dependencies” of the Project.
How the Unity Package Manager installs packages
If you want to include a package in your Project, you must update the Project manifest to include it in the list of dependencies. If you want to, you can modify the Project manifest directly, but it is safer and easier to let the Package Manager do that. For more information on using the user interface, see the documentation for the Package Manager window.
How to use the Package Manager
The Package Manager uses three interfaces to communicate with users, manifests, and registries:
Unity Package Manager
Unity — платформа, которая существует довольно давно и постоянно развивается. Однако, работая в ней с несколькими проектами одновременно, все еще можно столкнуться со сложностями в использовании общих исходников (.cs), библиотек (.dll) и остальных ассетов (изображения, звуки, модели, префабы). В этой статье мы расскажем о нашем опыте работы с нативным решением такой проблемы для Unity.
Методы распространения общих ресурсов
Существует больше одного способа использовать общие ресурсы для разных проектов, но у каждого подхода есть свои плюсы и минусы.
1. Дублирование — «руками» дублируем ресурсы между проектами.
Unity Package Manager
Unity Package Manager (далее UPM) — инструмент для управления пакетами. Его добавили в Unity 2018.1, и он использовался только для пакетов, которые разрабатывались Unity Technologies. Однако начиная с версии 2018.3 появилась возможность добавления кастомных пакетов.
Интерфейс Unity Package Manager
Пакеты в файловой системе проекта
Источники пакетов
UPM может использовать несколько источников пакетов:
1. Файловая система.
В качестве npm-репозитория можно использовать Verdaccio. К нему есть подробная документация, и для его запуска потребуется буквально пара команд.
Настройка окружения
Для начала нужно установить node.js.
Создание пакета
Отправка пакета
Установка и обновление пакетов через Unity Package Manager
Чтобы добавить пакет в Unity-проект, нужно:
Работа с исходниками и отладка
Чтобы исходники подключились к проекту, необходимо создать Assembly Definition для пакета.
Использование пакетов не ограничивает возможности для отладки. Однако при работе с пакетами в Unity нельзя перейти в IDE по клику на ошибку в консоли, если ошибка произошла в пакете. Это связано с тем, что Unity не видит скрипты как отдельные файлы, поскольку при использовании Assembly Definition они собираются в библиотеку и подключаются к проекту. При работе с исходниками из проекта переход в IDE по клику доступен.
Скрипт в проекте с подключенным пакетом:
Скрипт из пакета с работающим брейкпоинтом:
Срочное внесение исправлений в пакеты
Добавленные в проект пакеты Unity открыты только для чтения, но их можно редактировать в кэше пакетов. Для этого необходимо:
Конфликты импорта пакетов
При импорте пакетов могут произойти следующие конфликты GUID’ов:
Перенос ассетов из проекта в пакет
Если перенести ассет из проекта в пакет при открытой Unity, то его функциональность сохранится, а ссылки в зависимых ассетах начнут использовать ассет из пакета.
Важно: при копировании ассета из проекта в пакет произойдет конфликт «Пакет — проект», описанный в разделе выше.
Package Manager window
Use the Unity Package Manager (in Unity’s top menu: Window > Package Manager) to view which packages are available for installation or already installed in your project. In addition, you can use this window to see which versions are available, and install, remove, disable, or update packages for each project.
The Package Manager window
The Package Manager window displays:
(B) The add button, which you can click to install a package directly into your project by entering a git URL or a local path.
(C) The Packages drop-down menu, which you can use to change what appears in the list (context).
(D) The Sort drop-down menu, which lets you sort the list of packages by name or date.
For Asset Store A growing library of free and commercial assets created by Unity and members of the community. Offers a wide variety of assets, from textures, models and animations to whole project examples, tutorials and Editor extensions. More info
See in Glossary packages, two additional controls give you some additional filtering options:
The Filters drop-down menu and the Clear Filters button allow you to narrow down which Asset Store packages appear in the list
(E) Advanced settings , which you can use to access the project settings A broad collection of settings which allow you to configure how Physics, Audio, Networking, Graphics, Input and many other areas of your project behave. More info
See in Glossary for the Package Manager or reset your project’s packages to default.
(F) The search box, which you can use to look for packages by name.
(G) The packages list view, which displays all packages that match the filter and search parameters you specify.
(H) The package-specific detail view, which displays information specific to the package selected in the list.
(I) The status bar, which displays information when Package Manager loads packages. This includes errors and warning messages, the number of Asset Store packages available, and a link to load more Asset Store packages.
(J) The reload drop-down menu, which lets you force Package Manager to reload or resolve the packages in your project.
(K) Buttons to install or update a package (or the Up to date message if the selected version is already installed.)
(L) Buttons to remove or disable the package.
Advanced settings
The advanced settings drop-down menu allows you to perform these actions:
Drop-down menu item | Action results |
---|---|
Advanced Project Settings | Select this item to open the Package Manager project settings, where you can: — Add, edit and remove scoped registries in your project. |
Reset Packages to defaults | Select this item to return to Package Manager default settings. Warning: This removes all customization from your project manifest file. Only use this as a last resort when you can’t figure out what is wrong with your project manifest file. |
Status bar
The Package Manager displays messages in the status bar at the bottom left of the Package Manager window.
There are typically four status messages that you might see:
The first time you open the Package Manager window in a new project, the Loading packages message appears briefly:
Loading packages message
This message also appears when you click the reload button.
When you are using the My Assets context, the load bar appears above the date. It displays the number of Asset Store packages and a numeric link to load more packages:
The load bar displays the number of Asset Store packages loaded vs. the total number available (A). Click the numeric link on the right (B) to load more (in this case 14).
Most of the time the status bar displays the date and time of when the Package Manager window last refreshed its information:
Last update message
However, if the Package Manager detects a problem, such as a missing network connection, the Package Manager displays an error in the status bar:
Network error message
If your network connection is working, but you are not signed into your Unity account, the Package Manager doesn’t display any Asset Store packages. When you try to use the My Assets context, the Package Manager displays an error in the status bar:
Logged out of Unity account
In the list view, click the Sign in button to sign into your Unity account through the Unity Hub.
For information on how to resolve these errors and more, see Error messages.
Unity Package Manager
A package is a container that holds any combination of Assets, Shaders, Textures, plug-ins, icons, and scripts that enhance various parts of your project. Unity packages are newer, more tightly integrated versions of Asset Store packages, able to deliver a wide range of enhancements to Unity.
Use the Unity Package Manager window (in Unity’s top menu: Window > Package Manager) to view which packages are available for installation or already installed in your project. In addition, you can use this window to install, remove, or update packages for each project.
The Package Manager window displays a list view on the left and a detail view on the right.
Finding packages
By default, the Package Manager window displays the list of packages in the In Project mode, so that only the packages already installed in your project appear in the list.
To expand the list to include all available packages, click the All button. The list now displays everything registered in the package registry, regardless of whether they are already installed in the project.
Viewing package details
The pane on the right side of the Package Manager window displays details about the selected package.
These details include the following information:
Version tags
Some packages display tags next to the version number. These tags convey information about that version of the package.
The Package Manager uses the following values:
Tag | Meaning |
---|---|
verified | Unity’s Quality Assurance team has officially verified that this package works with a specific version of the Editor. |
preview | This package is at an early stage of the release cycle and may not have been documented and fully validated by either the development team or Unity’s Quality Assurance team. |
A Package without a tag is considered production quality.
Finding more information
You can find out more about a package by viewing its documentation.
To access it, click the View Documentation link in the Details pane:
The package documentation page opens in your default browser.
Accessing the Package Manager window
You can perform a variety of tasks through the Package Manager window:
To open the Package Manager window, navigate to Unity’s main menu and go to Window > Package Manager.
Package Manager»>
Installing a new package
To install a new package:
Removing an installed package
To remove an installed package:
Notes:
Updating an installed package
You can update a package while in either the In Project or All mode:
Advanced package topics
This section provides more advanced information about the package manifest file. You don’t need to know anything about these topics to install, remove, and update packages.
In addition to its contents (Assets, Shaders, Textures, plug-ins, icons and scripts), a Unity package contains a package manifest file. The package manifest tells Unity how to display its information page in the Package Manager window, and how to install the package in the project.
In addition, it contains several files that help manage the package deployment, including the tests, the samples, the license, the changelog, and the documentation.
Manifests
There are two types of manifest files: project manifests ( manifest.json ), and package manifests ( package.json ). Both files use JSON (JavaScript Object Notation) syntax to communicate with the Package Manager, by describing which packages are available for each project, and what each package contains.
Project manifests
Project manifests ( manifest.json ) tell the Package Manager which packages and versions are available to the project.
Project manifests support the following value:
Key | JSON Type | Description |
---|---|---|
dependencies | Object | List of packages for the Package Manager to load. These are usually packages officially registered with Unity. |
Example of a manifest.json file:
Unity stores each project manifest in the [your_project_root_folder]/Packages/manifest.json file.
Package manifests
The Package Manager uses package manifests ( package.json ) to determine which version of the package to load, and what information to display in the Package Manager window.
Package manifests support the following values:
Example of a package.json file:
Unity stores each package manifest in the [your_package_root_folder]/package.json file.
The Package Registry
Unity maintains a central registry of official packages that are available for distribution. When Unity loads, the Package Manager communicates with the registry, checks the project manifest file, and displays the status of each available package in the Package Manager window.
When you remove a package from the project, the Package Manager updates the project manifest to exclude that package from the list in In Project mode but it is still available in All mode because it is still on the registry.
When you install or update a package, the Package Manager downloads the package from the registry.
Technical details
Requirements
This version of Unity Package Manager is compatible with the following versions of the Unity Editor:
Known limitations
The Package Manager includes the following known limitations: