The short version: Want a better way to share re-usable code and assets (either your own, or third-party content such as Asset Store assets) between multiple Unity projects? Projeny is a great free tool for that!
While I was developing Plantasia I was also creating some scripts and tools – a little visual state machine tool, a simple localisation helper, etc. that I was intentionally keeping project-agnostic so I could use them again in future games.
Out of the box, Unity doesn’t provide a nice way of handling this beyond simply copy-and-pasting files between projects. But that can quickly become unmanageable. What happens when you need to make a change? You’d have to manually apply it to all of your projects.
Similarly, when I decided to publicly release the game’s source code and assets I needed a better way to manage assets from the Unity Asset Store. Even though everything I was using was free, the Asset Store EULA only permits use of assets as part of a larger whole (such as a game):
“It is emphasized that the END-USERS shall not be entitled to distribute or transfer in any way (including, without, limitation by way of sublicense) the Assets in any other way than as integrated components of electronic games and interactive media.”
Which means you’re not allowed to upload assets to source control repositories, for example. Technically this also applies to Unity-developed assets, although I don’t think Unity has ever actually enforced that particular rule. Still, better safe than sorry!
So that leaves us with two project management problems we want to solve:
- Easily share re-usable source code and assets between Unity projects
- Keep third party content (e.g. asset store assets) separate from the main project
I investigated several possible solutions at first. Git’s Submodules allow for multiple, nested repositories, but it’s not a great solution in this scenario. Unity’s Package Manager is undergoing a big overhaul and could be a great solution one day, but currently it only works with Unity-developed assets.
Enter Projeny: a free, open source (MIT license) tool that enables division of projects into re-usable packages that facilitate sharing of code and assets between Unity projects, smoother platform switching, dependency tracking, and more. Although it’s only available for Windows currently.
It works by using Windows’ symbolic links, which allow for a folder to be treated as if it’s in one location despite actually being in another. In this way we can keep shared content in one place (which can use source control) but setup links in several Unity projects which will treat that content as if it lives in their own assets folder!
The GitHub page has some very detailed instructions for installation and setup, but I also found this more condensed cheat sheet useful. Plus there’s a handy demo project that you can see how to setup and take a look at in this video.
Here’s how the folder structure for Plantasia looks after setting it up with Projeny. The ‘Source’ folder at the bottom of the hierarchy is a Projeny package which contains the game’s actual code and assets. This is pulled into the Unity Assets folder for each of the platform-specific projects that live above it in the hierarchy.
By having one project per platform, Projeny also makes it much quicker to swap between platforms throughout the course of a day of development. No more reimporting and compiling assets every time you switch platforms!
Projeny offers a lot of flexibility when it comes to where you can store your Projeny packages. They can belong solely to one project (i.e the “Source” folder), be shared across related Projeny projects (via the “UnityPackages” folder) or stored in basically any other shared folder on your system.
Inside Unity, the Projeny Package Manager UI can be used to easily view all of the Projeny packages on your system (from any of the locations defined in various config files) and subsequently pull only the required packages into the current Unity project via either the “Assets” or “Plugins” folder.
I’ve currently defined a shared folder of Projeny packages that contains my own custom libraries as well as assets I’ve downloaded from the Unity Asset Store. This way I can keep everything up-to-date and source-controlled in one place while guaranteeing that any projects which use them will always have the latest version. Perfect!
Hopefully this provided some useful info for your own Unity projects! But maybe you already have an alternative solution for managing content across multiple projects? If so, please do leave a comment below!