Create custom packages
Understand the development workflow for creating new UPM packages.
Read time 6 minutesLast updated 16 days ago
The Unity Package Manager is the official package management system for Unity. It does the following:
- Allows Unity to distribute new features and update existing features quickly and easily.
- Provides a platform for users to discover and share reusable components.
- Promotes Unity as an extendable and open platform.
You can use the Package Manager to define project dependencies, resolve package dependencies, download packages, add packages, and integrate content in your projects.
For general information on what a package is and how the Unity Package Manager works, refer to Get started with packages.
Overview
Packages can contain the following:
- C# scripts
- Assemblies
- Native plug-ins
- Models, Textures, animation and audio clips, and other assets.
Each package also contains a Package manifest file that includes information such as the package name, its version, a list of its dependencies, and the URL to its repository.
Procedure
To create a new package:
-
Create an empty shell for the package using one of these methods:
-
Make sure the layout of your folder structure follows the package layout convention for Unity packages. For example, if you have Editor and Runtime libraries, make sure you store them under theand
Editorfolders.Runtime -
If your package includes code, make sure the package layout you created has the necessary assembly definition files. For information about creating and defining assembly definition files, refer to Assembly definition and packages. For additional information, refer to Assembly definitions.
-
Add your tools, libraries, and any assets your package requires.
-
Add tests to your package. Tests are essential for ensuring that the package works as expected in different scenarios:
- Write all your Editor tests in .
Tests/Editor - Write all your Play mode tests in .
Tests/Runtime
- Write all your Editor tests in
-
If you have samples for your package, add them to the proper samples subfolder.
-
Update thefile every time you publish a new version. Identify new features, important changes, and major bug fixes in this file. For more details on the chosen changelog format, refer to the Keep a Changelog documentation.
CHANGELOG.mdThis step is optional for packages that you don't share, but strongly recommended for shared packages, so that users know which version best suits their needs. -
You can include licenses and third-party notices in theand
LICENSE.mdfiles.THIRD PARTY NOTICES.mdThis step is optional for packages that you don't share, but strongly recommended for shared packages, so that your users don't misuse your packages or violate any third-party licenses. -
Document your package.
-
Share your package.
Creating a new embedded package
Follow these instructions if you want to create a custom package inside your project folder.
-
Open the Unity Hub, and create an empty project on your computer.You can also use an existing project on your computer, and embed the package under your project or install the package from a local folder. However, starting with a new project makes the package contents less prone to errors.
-
Using your computer's file manager (for example the Windows File Explorer or the macOS Finder), navigate to your project folder and locate thesubdirectory.
Packages -
Create a new subdirectory for your package inside thefolder using a name that matches the package name and follows the naming conventions. For example, if your package name is
Packages, create a subdirectory calledcom.example.mypackage.com.example.mypackage -
Open your preferred text editor and create a JSON file calledin the root of the package folder.
package.json -
Fill out all required and recommended fields in thefile. You can use the package manifest example as a reference.
package.json
When you reopen Unity, the new package appears in the Package Manager window and in the Project window, where you can view and modify the package contents. If you select the file in the Project window, you can also modify its JSON values directly in the Inspector window.
package.jsonReturn to the main procedure to complete the creation of your package.
Creating a new local package
Follow these instructions if you want to create a custom package outside your project folder.
-
Using your computer's file manager (for example the Windows File Explorer or the macOS Finder), create a folder for your package.You can also use an existing location if you have already created some content for your package.
-
Open your preferred text editor and create a JSON file calledin the root of the package folder.
package.json -
Fill out all required and recommended fields in thefile, making sure the
package.jsonproperty follows the naming conventions. You can use the package manifest example as a reference.name -
In Unity, create a new project or open an existing project.
-
Open the Package Manager window and follow the instructions for installing a local package, using thefile you just created. This step is essential for ensuring the creation of the required
package.jsonfile..meta
The new package appears in the Package Manager window and in the Project window, where you can view and modify the package contents. If you select the file in the Project window, you can also modify its JSON values directly in the Inspector window.
package.jsonReturn to the main procedure to complete the creation of your package.