Should I ship my packages with meta files?

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?

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.

.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

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.

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

thanks, of course my observations where relative only to the distribution of packages with source code only.

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.

Yes.

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