A Project Structure for Your Open Source Unity Packages

A tidy project is a project that is easier to work with

Andrew Lord
Nov 20, 2016 · 3 min read

This article is now deprecated! The techniques discussed here should still work, however, the article is no longer maintained or updated. This means any code samples or Unity configuration may become out-of-date. Please check out Lord Codes for my latest articles. 🙏

When you start writing the code for your package, you will find that there isn’t really any form of enforced project structure. A clear project structure that keeps things nice and organised is usually the best way to go, especially important if other people need to read through your code.

The project structure I use is:

  • build: any builds and log files
  • reports: any test result files
  • release: to store your package for download
  • scripts: for use by yourself or CI to build, run tests etc.
  • src: the source code of the package itself

From Unity, select to create a new project, where you will enter its name and choose the src folder from above as the project location. Doing this will create a folder within the source directory that contains the Unity project. Alongside these files you will want to put a Unity project .gitignore, such as the one I propose below.

At the root you can add a very simple .gitignore so that the builds and tests results aren’t committed to Git.

Moving onto the Unity project itself, you will have an Assets folder to contain all of your project’s assets, such as source files, images and materials. To ease the process of exporting the package later I like to have one folder within here for the package sources and another with a .UnitTests suffix for all the unit tests. Any scenes (for testing the build) or other files are kept within Assets but out of the package sources folder, so that you can export everything in there to make your package.

For example, for MySuperLibrary I would have:

  • Assets/MySuperLibrary/: Package sources
  • Assets/MySuperLibrary.UnitTests/: Unit test sources
  • build.scene: scene file to test the build

That’s about it, be sure to let me know if you can think of any improvements to the structure. Enjoy!

Please feel open to reaching out to me on Twitter @lordcodes with any questions or thoughts you have, or about anything else. Please also check out Lord Codes for my latest articles.

Thanks for reading and happy coding! 🙏

Andrew Lord

Written by

Mobile Development Lead @GetBusyHQ. Builder of Android and iOS apps. Blogs at www.lordcodes.com . Coder, avid gamer and music fan.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade