Structuring an npm package for Unity
As with all npm packages; each package requires a “package.json” file to identify the package and any dependencies that it may have.
The unity3d-package-syncer tool will automatically synchronize packages that have the “unity3d-package” keyword in the “keywords” section of the “package.json” file.
The directory structure of the package is entirely up to you; however any assets, scripts or DLLs that are to be synchronized into Unity projects must be placed inside the “assets” folder of your npm package. There should be a “README.md” and “LICENSE” file at the root of the package since these will also be synchronized into Unity projects.
The minimal directory structure would look something like this:
my-package/
|-- assets/
| |-- Editor/
| | |- ExampleBehaviourEditor.cs
| | |- ExampleBehaviourEditor.cs.meta
| |-- Source/
| | |- ExampleBehaviour.cs
| | |- ExampleBehaviour.cs.meta
| |-- Editor.meta
| |-- Source.meta
|-- README.md
|-- LICENSE
|-- package.json
Note - It’s important to include .meta files for source files since this helps Unity to maintain links between scripts and assets.
A minimal “package.json” file would look something like this:
{
"name": "my-package",
...
}