Custom Packages With Version Numbers

I’ve trying to make a custom package that will let me distribute a plugin, and associated assets on a private basis.

If I update the assets or the plugin - how do I give it a version so it can be seen in package manager by my customer

is this even possible?

Hi @ ,

It sounds like you want a private registry. With a private registry, you can publish new versions of your package and they will be listed in the Package Manager window for any Unity project that points to that registry. You can even have a project that points to Unity’s registry as well as your own. This feature is called “scoped registries” and is described here:

If setting up your own registry server is not feasible, there are other ways of sharing your package privately such as through a Github repository. Let me know if you want more details!

hi @samuelb_unity

yes, I’d like to know more about how to do this through a git repo (although most likely to bitbucket than github)

thanks

Sure, in the Package Manager window you can click the + button and Add package from package ID.... The package ID should be in the format @ where the URL ends with “.git”. For more information on formatting the URL (such as specifying a branch or specific commit) see here:

If you open your project manifest (/Packages/manifest.json) you will see the git package has been added to “dependencies” and a “lock” attribute is set. This means your Unity project is locked to that specific revision of the repo e.g.

{
  "dependencies": {
    "my-package": "https://bitbucket.com/my-package.git"
  },
  "lock": {
    "my-package": {
      "hash": "abc123",
      "revision": "HEAD"
    }
  }
}

If you push a new revision and you want your project to get it, simply delete the whole “lock” entry and Package Manager will grab the latest i.e.

{
  "dependencies": {
    "my-package": "https://bitbucket.com/my-package.git"
  }
}

Be careful not to leave any trailing commas behind as this is not valid JSON

2 Likes

Thanks.

Is this “lock” deletion a one-time-only affair or each revision?

You will have to delete the lock (or add the package again) every time you want to fetch the latest revision. This is by design because, for example, 2 people on the same project should always get the same packages. There might be plans in the future to make this easier through the Package Manager window e.g. an “Update to latest” button.

4 Likes

You can add a branch name at the end:

"my-package": "https://bitbucket.com/my-package.git#branch"

and use the branch name as a version ID to switch between versions back and forth with no need to delete the “lock” section.

1 Like

Yep, or you could stay on the same branch and use tags to differentiate version releases. In fact, any commit-ish identifier can follow the # symbol.