Is there a standard/recommended directory structure for Unity projects?

后端 未结 2 1117
误落风尘
误落风尘 2021-02-04 14:00

My next project will use Unity 5.6. It will be a game and that will leverage AssetBundle for remote scenes loading. New scenes will be incrementally added afterward. Therefor

相关标签:
2条回答
  • 2021-02-04 14:08

    At the end of the day, it comes down to whatever works the best for you and makes the most sense for the project. Working on small solo projects, I've found that keeping a simple folder structure separating asset types has worked well to keep things organized (Textures, Scripts, Prefabs, Sprites, etc). Another popular method is to organize by object type:

    Animals
    ├── Crow
    │   ├── script
    │   └── sprite
    └── Snake
        ├── script
        └── sprite
    

    In my experience, organizing by Scene has generally not ended up working out well, especially in the case where assets are shared between scenes - stuff tends to get lost.

    I suggest taking some time to mess around with your organization and see what feels right for you, especially if this is your first unity project. Moving files around after you start will not break associations in the inspector, assuming you are not searching through directories in your scripts.

    If you need more help deciding, take a look at some of the links below. Link 3 in particular has a pretty lengthy discussion on this topic.

    • Mastering Unity Project Folder Structure. Level 2 – Assets Organization
    • 50 Tips for Working with Unity (Best Practices)
    • Unity Forums: Best practices - Folder structure
    0 讨论(0)
  • 2021-02-04 14:09

    Unity actually does encourage the following structure:

    Assets
    ├── Animations
    │   └── ...
    ├── Editor
    │   └── ...
    ├── Models
    │   └── ...
    ├── Prefabs
    │   └── ...
    ├── Scripts
    │   └── ...
    └── Textures
        └── ...
    

    This is due to the object oriented way in which Unity thinks: Each folder contains only the information of a certain type needed for an asset. This is especially visible when you look at the Special Folders in Unity.

    Even when you look at how they build up their standard assets you will notice this structure. I hope you won't have a lot of scenes which do not share any assets with the other scenes, because this would be a very big waste of resources.

    What is notable in the Standard Assets, is that in their demo, they have a folder called Menu which contains its own Scripts, Prefabs and Sprites folders.

    So I suggest you do the following (note: This is my opinion):

    • Try to separate everything into their own folders without grouping into assets but into filetypes
    • In some cases where scenes have their own assets that are never shared, you may group them into a separate folder
    • I really do not like the idea of "static assets" and "dynamic assets" in the folder structure as proposed by the blogentry of link1 ryemoss gave you. Dynamically loaded assets require you to use the Resources folder anyway, so use this folder instead and put your grouping folders ("Bundle1", "Bundle2", etc.) inside it.
    • Never mix your system. If you think something isn't fitting, change it. But change it for the whole project. Be consistent.
    • Do not force folders to be moved up or down by adding an underscore or something equivalent as prefix.
    • Document your structure somewhere. Depending how large your project is, it may help. But folderstructures are like code, if they don't need a comment to describe what's happening, its (mostly) best.
    0 讨论(0)
提交回复
热议问题