Search Unity

Should I ship my packages with meta files?

Discussion in 'Package Manager' started by sebas77, Dec 6, 2019.

  1. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    Hi,

    I would like to distribute the git repository of my package, but unless I am going to create a special version for unity (which I can do), I am not going to upload the .meta files too.

    As far as I understood the meta files must be shipped, is it correct?
     
  2. at_

    at_

    Joined:
    Oct 29, 2018
    Posts:
    24
    Your package might contain objects that reference each other. These references utilize hashes stored in .meta files.

    So yes, they should be included in your package.
     
  3. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    559
    .meta
    files must be version controlled as they define how Unity imports them (guid, import settings, etc. live there)
    also the package manager will error if a file in a read-only package does not have the corresponding
    .meta
     
  4. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    yes I understand that packages (weirdly in my opinion) can include resources that are not source code, but in case of source code only meta files could be generated by Unity instead to be versioned by me. Unity cannot generate them because the package folder is protected. Just saying there may be some way to fix this, if it's considered a problem at all. IMO the problem is that in this way pure c# libraries must be deployed on purpose for Unity.
     
  5. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    559
    usually, the .meta doesn't matter for (non-unity) .cs, folders and file types with a default importer (also scenes), but
    • labels
    • userData (arbitrary string accessible via api)
    • assetbundle name/variant
    are stored in the meta too.

    also, all assets (including scripts and folders) can be referenced via a
    UnityEngine.Object
    serialized field, and that requires the guid in the
    .meta
    file

    MonoBehaviour and ScriptableObject are also identified by the guid when attached to a GO / created
     
  6. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    thanks, of course my observations where relative only to the distribution of packages with source code only.
     
  7. pahe4retro

    pahe4retro

    Joined:
    Aug 13, 2019
    Posts:
    33
    As files in packages without a .meta file are ignored, you need to ship the corresponding meta files if you want to release your plugin for a unity project (at least via the package manager).

    The meta files contain a GUID which is used for referencing scripts (and other assets) inside the Unity project. I assume that is also the reason why you must include the meta files in your package.
     
  8. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Yes.

    It is also allows you to upgrade package without its user base loosing references to the assets.