Share your code across all of your Unity projects with ease!
Unity’s package manager has a hidden secret. It’s built on top of NPM. This offers us some amazing possibilities when it comes to writing our packages.
Through this article we’ll explore: what a Unity Package is; how to create a private package hosted on GitHub; add a full CI/CD pipeline to deploy it; and how to use that in your project.
What’s a package
So what makes up a Unity Package?
Looking at Unity’s Scriptable Build Pipeline we see 3 folders
- Editor
This is where any editor scripts will live, perhaps a tool window, some custom inspectors or other editor helpers. - Runtime
The meat and bones of the package, everything that comprises the runtime code of the package should live here. - Tests
A great place to store your tests.
Sticking each of these folders in your package helps you to maintain a good, consistent structure across your packages.
There are a few other notable files in here, the changelog, readme and license files are relatively standard but well worth adding to your packages if others will use them.
The really important file in all of this, however, is the package file.