Best Practices — 1 — Unity Project Structure
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#.
▶ Enjoying The Content?
▶ Enjoying The Content?
I am a Unity Game & Tools Developer with over 20 years of game development experience. I am available for hire (Remote, Contract).
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
Resources
📚References
- Best practices folder structure
- 7 Ways To Keep Your Unity Project Organized
- Unity3D Best Practices Folder Structure
- Unity Special Folders
🦜 Contact
- Samuel Asher Rivello has over 20 years of game dev XP. He is available for remote, contract hire as a game developer and game dev educator.
- Contact Sam today to say hi and discuss your projects!
📜 Articles
- Best Practices — 1 — Unity Project Structure
- Best Practices — 2 — Unity C# Coding Standards
- Best Practices — 3 — Unity Overview
- Best Practices — 4 — MVC Architecture For Unity
- Best Practices — 5 — Unit Testing For Unity
- Best Practices — 6 — CI/CD With Unity Buildalon
- Best Practices — 7 — Best Unity Asset Store Packages
- Unity — Game Architectures — Part 1
- Unity — Game Architectures — Part 2
- Unity — Game Architectures — Part 3
- Unity — uEvent & Custom ScriptableObjects
🛜 Downloads
💬Comments?
- Let me know! Twitter.com/srivello