Best Practices — 1 — Unity Project Structure

Samuel Asher Rivello
4 min readJul 11, 2020

--

Unity3D is a powerful suite of tools (Project IDE, Code IDE, and run-time) for game development. Unity supports several languages, but the community consensus is to use only C#.

I am a Unity Game & Tools Developer with over 20 years of game development experience. I am available for hire (Remote, Contract).

SamuelAsherRivello.com

Pros of Project Structure

Regardless of which convention you choose to use for Unity or other platforms, having a solid project structure is considered a good idea by the majority of the development community.

Having good coding standards and an established project structure is beneficial to your project and your team.

See my Coding Standards for C#.

A hallmark of Getting Things Done efficiently is to automate what can be automated. Once a team has standards and project structure and adopts them (both admittedly time consuming) the time improvements in the daily workflow are notable. There is less discussion on why or how to name things. It just gets done.

  • Consistency — The project structure has consistency in presentation regardless of team location, spoken language, or individual programmers.
  • Maintenance — Consistent project structure will aid readability. Readability helps new and existing programmers revisit the code base for fixes and improvements.
  • Communication — Developers more implicitly understand each other in written and verbal communication.

Root Folder Structure

Note here that “Unity” is a child of the root. This supports repos to scale up easily to have Unity and Non-Unity content as is often the case in production.

Here is the recommended structure. Download available below.

GitHubRepo
├── .gitignore
├── README.md
└── Unity
├── Assets
├── Packages
└── ProjectSettings

Assets Folder Structure

Let’s assume my company “RMC” has a project called “MyProject”.

Note that the “Art” folder consolidates the files most commonly touched by non-programmers. To aid team-workflow, these are centralized.

Here is the recommended structure. Download available below.

Assets
├── 3rdParty
│ └── [CompanyName]
│ └── [PackageName]
│ ├── Version.txt (With source URL, changelog)
│ └── [PackageName]
├── Art
│ ├── Animation
│ │ ├── AnimationClips
│ │ └── Animators
│ ├── Audio
│ │ ├── AudioClips
│ │ └── AudioMixers
│ ├── Fonts
│ ├── Materials
│ ├── Models
│ ├── PhysicMaterials
│ ├── Shaders
│ ├── Sprites
│ └── Textures
│ └── Timeline
│ └── UIToolkit
│ └── Resources
│ ├── Layouts
│ ├── Settings
│ ├── Styles
│ └── Themes
├── Documentation
├── Prefabs
│ └── RMC
│ └── [MyProject]
│ └── MyHeroPrefab (using MyHero.cs)
├── Presets
├── Resources
├── Scenes
├── ScriptableObjects
│ └── RMC
│ └── [MyProject]
│ └── MyHeroSettings (using MyHeroSettings.cs)
├── Scripts
│ ├── Editor
│ │ ├── RMC.MyProject.Editor.asmdef
│ │ └── RMC
│ │ └── [MyProject] (namespace RMC.MyProject)
│ │ └── MyHeroEditor.cs
│ ├── Runtime
│ │ ├── RMC.MyProject.Runtime.asmdef
│ │ └── RMC
│ │ └── [MyProject] (namespace RMC.MyProject)
│ │ ├── MyHero.cs
│ │ └── MyHeroSettings.cs
│ └── Tests
│ ├── Editor
│ │ ├── RMC.MyProject.Editor.Tests.asmdef
│ │ └── RMC
│ │ └── [MyProject] (namespace RMC.MyProject)
│ │ └── MyHeroTest.cs
│ └── Runtime
│ ├── RMC.MyProject.Runtime.Tests.asmdef
│ └── RMC
│ └── [MyProject] (namespace RMC.MyProject)
│ └── MyHeroTest.cs
└── Settings

Special Topic: UI Toolkit

UI Toolkit Folder Structure

Let’s zoom in on this excerpt from the folder structure above.

  • Resources — All assets are within Resources. Some may be loaded at runtime, so this simple folder structure supports that and is also clean and readable.
  • Scripts — I did not put a Scripts folder here. In the future, I might. Any ‘Layout’ component here can indeed be replaced with a C# component so it may make sense to have them sit in this section. For now, I use /Assets/Scripts/ for such cases.
Assets
├── ...
├── Art
│ ├── ...
│ └── UIToolkit
│ └── Resources
│ ├── Layouts
│ ├── Settings
│ ├── Styles
│ └── Themes
└── ...

Downloads

--

--

Samuel Asher Rivello

Game Developer & Instructor - Unity Certified. 20+ years of game dev XP. Available For Remote Hire. http://www.SamuelAsherRivello.com