Search Unity

Why unity need to create meta file for folder?

Discussion in 'Editor & General Support' started by Thaina, Jun 13, 2019.

  1. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,166
    I understood that unity need to create .meta file pair with asset. But why we need it for folder? Which is not really and asset and so should not require meta file isn't it?

    It not even commit empty folder in version control so meta file is really annoyance in this case. And it just increase the number of unnecessary file in the project

    Should the next version of unity remove meta file of folder, or at least could you just skip meta file generating for empty folder?
     
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,445
    If you buy a Flowers asset with a folder of flowers, then you move it to Purchased/Environmental/Landscaping/Flowers, then you later see that the artist added 15 more flowers, the installer will instantly be able to add the new content in the correct place.
     
    Thaina likes this.
  3. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    Additionally, thanks to the meta file (and guid) for the folder, it is possible to reference a folder as a UnityEngine.Object in a serialized context. This means, with some editor scripting we can draw a custom inspector field which lets users drag a folder asset into. This makes it possible for custom tools to load files from a special folder, which can then be moved by the user.

    So I strongly believe meta files are a good idea for folders. (At least within the current Unity guid-based serialization world)
     
    Joe-Censored likes this.
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Even if the meta files weren't necessary, I think it is a bad idea to change things like this unless there was a very important reason to do so. A few extra meta files, I don't see how they could be causing you headaches.

    I don't understand why you would have created empty folders, but aren't committing them to your version control. Maybe there is a use case for this that I'm not aware of.
     
  5. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    By the way, empty folders causing trouble with Unity may not be Unity’s fault, but a lack in features of the version control system. Git and Mercurial both don’t handle empty folders, but PlasticSCM, for example, does. Sure, there will be pros and cons for both approaches, but at least we can say that Unity’s implementation for folder guids is a valid approach.
     
    ASymShade likes this.
  6. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,166
    It's not like I was created myself. But it was part of many things. Such as when we remove or moving asset around. Upgrade plugins. Delete folder and commit to git then another machine pull it. Or any other reason that cause old folder to become empty