- Home /
Is it safe to share .meta files of scripts across multiple projects?
Here's my situation: I'm making a library/plugin that I'd like to be reused across many of my Unity projects.
Since I use Git as version control for all my projects, I would turn my library into a Git submodule. That means a separate Git repository for that library.
Which means the Unity .meta files of those files (C# scripts, GUI images, a Unity scene file, and fonts) will be shared on many Unity projects.
Could conflicts arise from such a thing? Even if Unity won't report any errors, would that corrupt the Library folders of my projects somehow? Take note that some of my Unity projects are in a Windows PC and some are in a Mac laptop. And I want to sync all of them properly.
Nice question! I use submodules too and I was really interested in any kind of answer/solution to this question. Have you figured something out?
I've just noticed that each .meta begins with a file format version may it's safe if you use the same format across projects? Example: fileFormatVersion: 2 guid: 7a4d8e09f0554452cbc0f0b2b6e27c13 $$anonymous$$onoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData:
Answer by Jamora · Jan 09, 2014 at 10:46 PM
The standard way (at least for me) is to
make a new Unity project for the library, which, in your case also syncs with git.
All required assets will then have to be exported into a package from the Assets menu (Assets -> Export Package). That package should be stored in Git as the 'build'.
Whenever you need that package in a different project, you download the Package from git and extract it into the project (using Assets -> Import Package -> Custom Pakcage).
This way, all meta data should stay intact and not cause any problems later on.
If your package consists only of code, it might be easier to just make a .dll out of it and place that into the Plugins -folder.
This way is like not use a submodule at all, isn't it? If I can't checkout into the submodule and update the relative repo, I think I loose all the advantages of using a submodule: if I'm working on a repo A using a submodule B, if I find a bug in the submodule B I can't fix it directly from the local git repo, but I have to open the relative project, fix the bug, rebuild the package and download it again into repo A.
No, you gain all the advantages of using a submodule; If you find a bug in your package, you fix it in one location, then release a newer version of it and everyone who was affected by the bug may download the fixed version.
According to my understanding of .meta-files as long as the relative folder structure is the same they should work. So if you force all users to download the assets from git to the same folder, say "/UnityProjectFolder/Assets/Sub$$anonymous$$odule/", there should be no problems.