Best practices - Folder structure

Hi

Is there any best practices for sorting assets in folders in Unity?

Have been doing something like this:

Assets
+Scenes
+Common
+Materials
+Textures
+Objects
+Scene01
+Materials
+Textures
+Objects
Scene01.unity

+Scene02

How do you structure your assets?

Cheers,
Tobias

2 Likes

Whatever works for you and the project is the best. I don’t use the same structure for everything.

–Eric

1 Like

I try to make sure that whatever I do is as malleable as possible, so as the project expands, I can reorganize if necessary. Unfortunately, Unity isn’t the only environment that needs to be managed. For me, I have a bunch of Blender files that require links to assets, also. It’s a huge pain in the bee-hind to have to worry about this and I’d love for someone to give me a solution; I can move assets in Unity, or I can move them in Blender, but either way, everything will break. (I am sure there are other cases like this, but Blender is the only one for me currently.) Blender-aid helps but I think a web interface is a terrible idea, and last time I used it, anyway, it couldn’t even see .psd files.

In general there are two main approaches to organize assets: by type or by relevance.

First option works good with small projects, second one is better for huge games, also you can combine and get something in middle, e.g. our team is working on a MMO, folder layout we use looks like:

More about how our team organize assets you can read in our blog: http://developers.nravo.com/mastering-unity-project-folder-structure-level-2-assets-organization/

5 Likes

If n people reply to this thread, you’re going to get at least n+1 different answers. :wink:

There’s a useful folder structure in 50 Tips for Working with Unity (Best Practices) – Dev.Mag, but I think it works better for smaller projects.

Here’s my input:

I always keep my project-specific files in a single folder (e.g., Assets/Project) and let the rest of the Assets folder be a wild jungle of third-party products from the Asset Store. If you move all your third-party products to a subfolder (e.g., Assets/Plugins), it still often breaks some of them, so I prefer to leave them where the developers put them.

In Assets/Project, I organize by relevance. This allows for easier division of labor in a team.

18 Likes

This is interesting and I’m hoping that a lot more people will post their conventions :slight_smile:

I’ve been working on my project for a little over 18 months now and I’ve restructured my folders three times, I think.

  • First I tried something very similar to the OP, one folder per scene (for scene-specific assets) and one “Global” folder (and subfolders for models, scripts, sounds and so on), but this didn’t work out so well (lots of scrolling in the tree when assigning scripts).
  • Next I tried it with category folders on the root level (“Enemies”, “Player”, “CutScenes”, “Items”, “Buildings”) but that didn’t help any
  • Finally, I settled on having 5 root-level folders containing one nested category folder under which I sort for asset type (because this optimized my workflow: when I’m coding, I usually only look at code files, when I’m modeling, I only look at models, and so on)
    I’ve now got 5 root-level folders, (“External” for 3rd party components, “Framework” for things not specific to one game, “Game” for things tailored to the game, “Scenes” for scenes and “Resources” is Unity’s special runtime-loaded resources folder).

Beneath these, I one folder per category (eg. “Actors” are active things like enemies, cars, etc.) which by convention contain nested folders named “Code”, “Models”, “Sounds”, “Editor” and/or “Prefabs”

13 Likes

2 Likes

Since this thread got revived, I’ll reiterate my experiences having worked on dozens more projects with several groups since my last post.

  • Don’t move third-party Asset Store products. Leave them in their original import locations. Some of them still expect to run in hard-coded paths. Also, if you update a package that contains new files, the new files will be imported into the original import location, which makes a mess. Finally, if you’re collaborating, team members will have a better idea of where to find things if you leave them in their original locations.

  • The only exception is moving code-heavy products into Plugins to optimize compile times. But mind the caveats above when doing this.

  • Organize your own assets (code, textures, models, etc.) under a single folder. I prefer “__Project” because the underscore makes it sort to the top of the folder list. Or maybe two folders, “__Project” and “__Framework” (or “__Game” and “__Common”), if you also have a common framework that you share among projects. You might even name the common framework folder “__ReadOnly” or “__DoNotEdit” to remind people not to edit the contents since you probably want to edit the original files in your common framework project, not the copies in your active project. (I use two underscores because some third party assets use folder names with one underscore. This helps ensure that my project folders sort to the top.)

  • Inside “_Project”, organize folders to maximize your team’s workflow. Art assets tend to be the problem area since there are usually so many files.

  • If your game is divided into sections (e.g., levels) with distinct sets of art, consider folders for each section (e.g, Mushroom Kingdom, Sewers, Dracula’s Castle, etc.). When your artists are working on the Sewers section, they can quickly find everything the Sewers folder structure without having to dig through Mushroom Kingdom and Dracula’s Castle assets.

  • If your game reuses most of its art across levels, consider folders for each function instead: Scenes, ParticleEffects, Characters, etc.

  • I’ve found that it works best to group all assets related to an entity in a single folder. So, for example, you might have a “Dragon” folder with subfolders for Dragon-specific textures, models, animation, particle effects, and audio clips. If an artist is going to be working on the Dragon, he or she will probably be touching most or all of these in the same work session.

  • The goal is to establish a folder structure that allows artists to find assets easily and avoid messing with assets that they’re not currently working on.

  • For really big endeavors, like an MMO or a full length content-heavy game, use multiple Unity projects. That’s a topic unto itself, and there are threads on the forum about it.

18 Likes

Hah! Yep, I use “_Game” for my actual implementation. Then, all third party assets go wherever they go. If they don’t go in a single folder, shame on them. I actually repackage those so that they are contained in their own folder.

My tree goes like this:

_common
_game
Animation
Editor
Prefabs

Resources

Scenes
Scripts

UI
atlas
images
fonts
prefabs



“_common” is actually a symlink to my UnityCommon folder that contains all scripts that I write and share between all my projects, like utility code.

5 Likes

I’ve just started thinking about this and naturally organised by feature/theme rather than by scene or base-type.
Obviously there’s some re-use across objects, so it’s not all great. But I tend to think in terms of ‘features’ or clumps of features, and want to see the entire makeup of an object in one view without hunting. Does anyone get into a pickle with this type of layout? I can imagine if you just want a list of all prefabs, it’s a little annoying.

Planets
Textures
Prefabs
Mats
ParticleEffects
Scripts

Spaceships
SpaceshipA
as above
SpaceshipB
as above

Asteroids
ditto…

1 Like

I find this thread pretty interesting… the concept of organizing information, efficiency access to files you need, and the accumulation of wasted time doing mundane tasks like squinting your eyes looking for which folder has which file in it (which would be accurately classified as an inefficiency in gamedev which could cost you many work hours over time).

This is important IMO, because GameDev is an extremely lengthy & complicated process. This means that what most people will see as irrelevant (spending a few seconds to sort through files or folders) is in reality minutes which add up thousands of times over the years - which means hours. At least in theory, anyway.

Furthermore I absolutely hate posts like “It depends!” - entirely dismissive posts with absolutely no content. They are equivalent to spam posts “askjedhasgkdfhweiujsfhnweijfn” and are IMO an unintelligent cop-out for someone who doesn’t actually want to think or doesn’t grasp this isn’t simply subjective.

We’re not asking “What is your favorite color?” or “What food tastes the best?” Nope. We’re talking about organizing information. This is something those of us in the field of Psychology actually study. Our brains handle information in a very human way (i.e. the same way). For example we are programmed to identify simple icons much more quickly & accurately than a huge wall of jumbled text (tons of folders/subfolders/file-names which all blend together to be “some text” which you must squint your eyes, go into detail, and figure out with tangible effort “Where is that file I need?”

Search functions of varying complexity, tag systems (like those used in Unity Answers to organize Questions), and alternative visual representation of language are all tangible methods - and often superior methods at that.

It is not someone’s “Opinion” that you should use the search function to find a file by a specific name when you don’t know its location. It’s not an opinion or “taste” that easily identifiable icons are a better idea than text when you need to identify symbols. Having different colors for different icons, like with Rainbow Folders, is factually superior than not having it. You could prove in a study that this actually improves how quickly a user can identify folders/files.

Even Art is not always subjective. Color Theory is mostly about what actually looks good. It’s not an “Opinion” that specific colors on the spectrum are considered complimentary colors. If you think that’s an “Opinion” then you will produce bad or mediocre art at best. Those who know this stuff to be fact (within understanding of said theory) produce superior art. That’s actually a thing. For example Realism isn’t subjective. You don’t attempt to recreate what you see in real life, and have people “with different taste” who think it looks just as real. For example, If you draw a stick figure and claim it’s photorealism, you are just plain wrong. Another great example is coding conventions / standards - they exist for a reason. Readability is very important. In fact it is often more important than performance.

There are tangible ways to measure quality of a lot of “subjective” things. And organization of information is the least subjective compared to something like art (which as I stated, is not always subjective.)

If we weren’t so intellectually lazy and unmotivated to find better solutions, we could actually have solid advancement about best practices, organization, and user interfaces. (For example if you know anything of Bethesda, their content developers use the Creation Kit. I feel very sorry for them; it is a horrible application. So incredibly disappointing that so little effort is put into making a better interface. I would not work for such a company; all that money, and so little care for their employee’s sanity.)

17 Likes

I find the traditional method of Folder—>Subfolder—>Filename to be a bit inefficient.

I’d be much more interested in a search function, maybe using tags, or perhaps verbal communication to find specific files & a learning AI which gets used to your personal method of organization/thinking/language.

“Open Orc’s Animation Set” or “Open Orc’s Walking Animation” or “Show me every file related to the Orc.” or “Sort files by recently added; show only animations”.

No need for folders at all in such a system. I have no idea how it would work out… but I’m much more interested in using Icons, Colors, and intelligent functions (i.e. search) than a traditional folder hierarchy.

In fact I don’t really use Windows Explorer. I use “Everything” - an application which searches with instant results. When required, I copy/paste in a directory & search for file. For example to find screenshots for a specific game, "C:\Users\Administrator\MyDocuments\Game42" + *.png

But at least it has “Quick Access”. Unity (default) doesn’t even have such a thing, even though it’s superior to not having it.

“EVERYTHING” is such an amazing application - it has probably saved me hours of times & frustration. Always so easy to find anything in an instant. Perhaps this (and a few other features) should replace Windows Explorer entirely. I am not a fan of the current Folder system used to organize thousands of files & apps.

Your brain already knows “I am looking for an image” or “I am looking for a script” so when you go to browse your project (harddrive) you shouldn’t be seeing anything else. But typical methods for this type of thing is extremely inefficiency. There’s no quick access to instantly pick “Images only” with a single button. You often have to type this out in something akin to a command line.

4 Likes

From the top of my head and after reading this thread, I came up with 2 BASE models (there might be slight variations for each individual) :

Organizing assets by type of asset (script, animation, sound…):

Pros:

  • Keeps things better in perspective (subjective)
    Cons:
  • Searching for individual components that relate to that object might require additional clicks (locking inspector for a prefab and looking for the material/script etc.)

Let there X be:
Enemies
Player

Animation
X
Materials
X
Models
X
Prefabs
X
Scripts
X
Sounds
X
Textures
X

Organizing assets by type of object (enemy, tree, player…):

Pros:

  • More natural way of representing assets (subjective)
    Cons:
  • Will clutter the browser with a lot of folders once you expand it for an object (subjective)
  • Doesn’t help with shared Assets across objects (what happens if you have a non-duplicable asset like a script?)
  • Scatters the assets (subjective)

Let there X be:
Animation
Materials

Textures

Enemies
X
Player
X

Organizing by scene usage wouldn’t be ideal for projects that:
A) Would not require unique objects for each scene
B) Even if it did require unique objects per scene, you would still have to use one of the two methods above to organize them in the scene folder. This is a derived method.

If you have any suggestions/additions to this, reply :slight_smile:

2 Likes

The problem is that in gamedev, assets often have multiple uses.

For example there may be a single animation set for “Characters” who all share the same rig, but different meshes & textures for each various of a character (ex. Race/Class)

This is one reason why a folder system just doesn’t work. Something close to a tag system would be better, as a single file could then be in multiple locations at once (I’m not sure if Unity supports shortcuts in the Project tab; and that is cumbersome when adding/moving files).

What I do find useful is having Assets (textures, meshes, animations, etc.) separate from Prefabs.

Prefabs are what you actually use in games. Their components can be easily found by clicking in the prefab’s inspector.

So within the limits of a folder/subfolder system, you’d probably want to do something like…

Assets/Resources/
…/Textures
…/Animations
…/Meshes
…/Etc

And for Prefabs (things you actually use in the game)

Assets/Prefabs/
…/Characters/NPC
…/Characters/Player
…/Characters/Animals
…/Environment/Trees
…/Environment/Foliage
…/Etc/Etc

By having Prefabs completely separated from actual game files (art) and game logic (scripts) you can more quickly access what actually matters: Content.

In that regard, you could organize by when you actually use something.

“Creation” folder for Resources that are used to build the content for the game (Art, Music).
“Content” for files that are used to make the actual game (Prefabs, Scripts)

And stick to some standard where you use a Prefab to handle things rather than going directly to Resources.Load(). This way content creators (even if the same person as artist & programmer; you) don’t have to mess with art or scripts- they just deal with Prefabs (content). If they want to assign different music, then they change the music variable on a Prefab, in the Inspector.

I guess this would then be organized by “Profession”

Programmer —> Scripts
Artist —> Textures
Artist —> Music
Artist —> Animation
Designer —> Prefabs
Designer —> Scenes

This is not ideal though.

While I feel this handles art assets very well (I only have Textures, Animations, Animators, and Audio - and once I make the prefabs I never need to mess with this stuff ever again)…

It is still a Pain to sift through Scripts, Prefabs, etc. Rainbow Folders help, but the icons in the project tab are way too small.

3 Likes

I’d be interested in a new project tab entirely. While Rainbow Folders changes the project tab, it doesn’t do enough. The icons are too small to make any big impact, and the number of colors is too limited. You still have to mostly rely on text - which just takes too much time for the human brain to parse. You have to identify it as text, stop to read the text, and then think about what you read. This is way too many steps. With big, obvious icons, you simply identify the icon. “Tree Icon = Trees. I need to click that.” Easy.

Text are also just icons (symbols) but they all look identical; same colors; same style; and way too abtract. The word “Tree” doesn’t look like a Tree. It looks like a bunch of nonsense our brains have to figure out based on our language.

Yeah, sometimes the sheer quantity of folders i have to get through to get to where I want is too much, making me stop and think everytime I go to the next folder…

I wish there was a solution to read your mind and point you where you want to be at. There was a Mind Field episode from VSauce where they had a machine that could guess what you will do even your conscious self even knew! I thought that was amazing! Imagine being pointed to the right asset even before you consciously knew!

Here’s the excerpt from the episode in question:

2 Likes

I also like using labels instead of some impossible to follow folder schemes. Folders named after the type of its content is rather unhelpful. It needs a theme or scene or creator reference etc. which can all be defined by multiple label conventions.

2 Likes

That immediately made me think of what Pengocat just wrote:

@CarterG81 - Have you experimented with using asset labels? There’s also no reason why you can’t use asset labels in addition to a reasonable folder structure.

I think I provided reasonable rationales for the folder structures in my previous post, but I kind of only hinted at one that became important in a project recently. The developer has a project that had grown so large that they wanted to split it into multiple smaller projects, similar to the solution described in Schell Games’ Unite presentation. If the assets were sprinkled throughout the project, it would have been more challenging to reliably extricate them into their new, smaller projects.

2 Likes

Thank you; I was entirely unaware of asset labels. This is awesome!

1 Like

Off topic, but relevant to why I posted here.

@Raresh Looks like your Unity answers question relative to this was deleted entirely.

The power user involved probably didn’t like the fact I pointed out the links of “duplicate posts” he posted had absolutely nothing to do with the answer he closed. They weren’t even close to the same topic…it made no sense. Perplexing…like he didn’t even read what he was copy/pasting. Maybe he was drunk? lol :stuck_out_tongue:

Would be nice if we had a better system over there to remove actual duplicates. It’s a bit of a mess there.