Unity Editor supports NPM packages. It is way more flexible solution in comparison with classic Plugin that Unity is using for years. NPM package supports versioning and dependencies. You may update / downgrade any package very easily. Also, Unity Editor has UPM (Unity Package Manager) that makes the process even simpler.
This template repository is designed to be easily updated into a real Unity package. Please follow the instruction bellow, it will help you to go through the entire process of package creation, distribution and installing.
Use the initialization script to rename the package and replace all placeholders.
.\commands\init.ps1 -PackageId "com.company.package" -PackageName "My Package"This script will:
- Rename directories and files.
- Replace
YOUR_PACKAGE_ID,YOUR_PACKAGE_NAME, etc. in all files.
-
Update
package.jsonOpenUnity-Package/Assets/root/package.jsonand update:descriptionauthorkeywordsunity(minimum supported Unity version)
-
Generate Meta Files To ensure all Unity meta files are correctly generated:
- Open Unity Hub.
- Add the
Installerfolder as a project. - Add the
Unity-Packagefolder as a project. - Open both projects in Unity Editor. This will generate the necessary
.metafiles.
To update the package version across all files (package.json, Installer.cs, etc.), use the bump version script:
.\commands\bump-version.ps1 -NewVersion "1.0.1"To enable automatic testing and deployment:
-
Configure GitHub Secrets Go to
Settings>Secrets and variables>Actions>New repository secretand add:UNITY_EMAIL: Your Unity account email.UNITY_PASSWORD: Your Unity account password.UNITY_LICENSE: Content of yourUnity_lic.ulffile.- Windows:
C:/ProgramData/Unity/Unity_lic.ulf - Mac:
/Library/Application Support/Unity/Unity_lic.ulf - Linux:
~/.local/share/unity3d/Unity/Unity_lic.ulf
- Windows:
-
Enable Workflows Rename the sample workflow files to enable them:
.github/workflows/release.yml-sample➡️.github/workflows/release.yml.github/workflows/test_pull_request.yml-sample➡️.github/workflows/test_pull_request.yml
-
Update Unity Version Open both
.ymlfiles and update theUNITY_VERSION(or similar variable) to match your project's Unity Editor version. -
Automatic Deployment The release workflow triggers automatically when you push to the
mainbranch with an incremented version inpackage.json.
Unity guidelines about organizing files into the package root directory
<root>
├── package.json
├── README.md
├── CHANGELOG.md
├── LICENSE.md
├── Third Party Notices.md
├── Editor
│ ├── [company-name].[package-name].Editor.asmdef
│ └── EditorExample.cs
├── Runtime
│ ├── [company-name].[package-name].asmdef
│ └── RuntimeExample.cs
├── Tests
│ ├── Editor
│ │ ├── [company-name].[package-name].Editor.Tests.asmdef
│ │ └── EditorExampleTest.cs
│ └── Runtime
│ ├── [company-name].[package-name].Tests.asmdef
│ └── RuntimeExampleTest.cs
├── Samples~
│ ├── SampleFolder1
│ ├── SampleFolder2
│ └── ...
└── Documentation~
└── [package-name].md
- Update the
README.mdfile (this file) with information about your package. - Copy the updated
README.mdtoAssets/rootas well.
⚠️ Everything outside of therootfolder won't be added to your package. But still could be used for testing or showcasing your package at your repository.
- Deploy to OpenUPM (recommended)
- Deploy using GitHub
- Deploy to npmjs.com
When your package is distributed, you can install it into any Unity project.
Don't install into the same Unity project, please use another one.
-
Open a command line at the root of Unity project (the folder which contains
Assets) -
Execute the command (for
OpenUPMhosted package)openupm add YOUR_PACKAGE_NAME


