unity-package-installer
A lightweight utility for installing npm packages into a unity project.
Background
This utility was inspired and informed by the work done by shadowmint; many thanks to him for blazing the trail. This utility encapsulates the boilerplate of installing packages into a Unity3D project.
Usage
Add unity-package-installer
as a dependency to your package.json
file. Information on the latest version can be found here.
"dependencies": ,
Automatic installation of packages
To subscribe to automatic installation of your package into a unity project after npm install
, add a unity_package_installer
config.
"config":
- source: A relative path to the folder to install in your unity project
- path: The name of the folder in unity to install to; if not provided then your package name will be used instead.
Manual installation of packages
You may elect to control installing your package via a post install script of your own.
"scripts": ,
The following example will copy the contents of sourceFolder
into Assets/Packages/My Unity Package
.
const PACKAGE_NAME = 'My Unity Package'; var installer = ;var path = ; // set the package source to ./../Files/My Unity Package/Sourcevar sourceFolder = path; // install the source into unityinstaller; // optional callback { // err - an error which occurred while trying to install your package // dir - the directory within the unity project that was source copied to}
As demonstrated, you may provide a callback to the installer if you want/need to perform additional actions after your files are copied into your project.
Enhancements
I plan on using this utility with something I'm developing now, and already have a few improvements in mind. If you think of any, please feel free to create an issue!
Bug reports
Please, file an issue if you notice anything not working as you think it should.