Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. We're running great holiday deals on subscriptions, swag and Asset Store packages! Take a peek at this blog for more information!
    Dismiss Notice
  3. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  4. Unity 2017.2 is now released.
    Dismiss Notice
  5. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  6. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  8. Unity 2017.3 beta is now available for download.
    Dismiss Notice

Best practices - Folder structure

Discussion in 'External Tools' started by tbjod, Oct 29, 2010.

  1. tbjod

    tbjod

    Joined:
    Feb 25, 2008
    Posts:
    19
    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. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,400
    Whatever works for you and the project is the best. I don't use the same structure for everything.

    --Eric
     
  3. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,327
    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.
     
  4. vzasadnyy

    vzasadnyy

    Joined:
    Jun 10, 2013
    Posts:
    13
    Last edited: Mar 11, 2014
    Daksmith likes this.
  5. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    7,178
    If n people reply to this thread, you're going to get at least n+1 different answers. ;-)

    There's a useful folder structure in http://devmag.org.za/2012/07/12/50-tips-for-working-with-unity-best-practices/, 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.
     
  6. Cygon4

    Cygon4

    Joined:
    Sep 17, 2012
    Posts:
    371
    This is interesting and I'm hoping that a lot more people will post their conventions :)

    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"

    $unity-directory-structure.png
     
  7. Bruno2Silva2

    Bruno2Silva2

    Joined:
    Mar 26, 2015
    Posts:
    17
  8. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    7,178
    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.
    • 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.
     
    Last edited: Aug 5, 2015
  9. aer0ace

    aer0ace

    Joined:
    May 11, 2012
    Posts:
    946
    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
    <game specific subfolder hierarchy>​
    Resources
    <game specific subfolder hierarchy>​
    Scenes
    Scripts
    <game specific subfolder hierarchy>​
    UI
    atlas
    images
    fonts
    prefabs​
    <third party>
    <third party>
    <third party>
    ...

    "_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.
     
  10. GilesDMiddleton

    GilesDMiddleton

    Joined:
    Aug 12, 2015
    Posts:
    82
    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..​
     
  11. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,644
    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.)
     
    Last edited: Feb 26, 2017
    reallytommy, IgorAherne and TonyLi like this.
  12. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,644
    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.
     
    Last edited: Feb 26, 2017
    reallytommy likes this.
  13. Raresh

    Raresh

    Joined:
    Feb 19, 2015
    Posts:
    5
    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 :)
     
  14. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,644
    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.
     
    Last edited: Feb 26, 2017
  15. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,644
    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.
     
  16. Raresh

    Raresh

    Joined:
    Feb 19, 2015
    Posts:
    5
    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:
     
    CarterG81 likes this.
  17. Pengocat

    Pengocat

    Joined:
    Dec 7, 2016
    Posts:
    140
    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.
     
    CarterG81 and TonyLi like this.
  18. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    7,178
    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.
     
    vintproykt and CarterG81 like this.
  19. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,644
    Thank you; I was entirely unaware of asset labels. This is awesome!
     
    vintproykt likes this.
  20. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,644
    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 :p

    Would be nice if we had a better system over there to remove actual duplicates. It's a bit of a mess there.
     
    Last edited: Feb 27, 2017
  21. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,400
    There isn't "a mod" on Unity Answers, or any mods, just users. Anyone with sufficient karma can edit/delete/etc.

    --Eric
     
  22. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,644
    Ah, that makes a whole lot more sense then :p

    Are they just seriously understaffed? StackExchange has tons of newbs spamming duplicates every day, but they clean up extremely well. Unity Answers is just.... bleh... so many duplicates... so unorganized... so chaotic. (Unlike what one user stated, it is not the users. All sites have newbies, ppl who dont read rules, etc. Idk what the problem is - maybe understaffed "mods" / no mods?)
     
  23. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    31,400
    It's not being understaffed; that's the structure of StackOverflow-like sites, where there isn't really staff as such. It's up to the users how much time/effort they want to put into cleanup etc.

    --Eric
     
  24. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,644
    Power users, mods, paid staff; that's all just semantics. If there aren't enough people to cleanup, I'd call that understaffed. It's a problem for Unity Answers, not for me, not for StackOverflow - just for Unity. And users will be driven away from answering questions when all they ever see are the same thing over & over.
     
    dadude123 likes this.