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

后端 未结 2 1118
误落风尘
误落风尘 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: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.

提交回复
热议问题