====== Meta Files ====== Unity uses .meta files for each asset you add to a project. These contain a GUID (unique identifier) and additional information about _how_ an asset should be imported, e.g. max texture size, compression settings, ... everything you change in the importer. All the information required to reconstruct the Library representation of an asset is stored in the meta file. * .meta files are important: always check them into source control, or you'll lose the ability to restore assets if you delete the library. * .meta files are powerful: they allow you to _replace_ assets if you know what you're doing. //Note: please make a commit / have a backup before attempting any .meta file magic. // ===== Swapping out a PNG file for a PSD ===== // or: how to replace a file without having to rewire everything // Say you have added a PNG file to your project and used it in a dozen places. Later, you realize that you actually need more control and want to "upgrade" to a PSD file. Usually you would have to * add the PSD file * find all places the PNG file is used // <- this is slow and error-prone // * use the PSD file instead * delete the PNG file But, with a bit of .meta file magic, you can // replace the file directly // and // keep all references //. Note: do not focus Unity during this procedure, otherwise .meta files will be created where you don't want them. * right click your PNG in Unity and show in Explorer/Finder * there's a "MyImage.png" and "MyImage.png.meta". * put your PSD file here; usually "MyImage.psd" but can also be "MyFancyImage.psd". * // rename // the meta file to now point to your new PSD file: "MyFancyImage.psd.meta" * delete "MyImage.png" * focus Unity That's it - the image is replaced // everywhere it's been used // and now points to the PSD file. This works because * the GUID is stored in the .meta file and used for tracking the reference * the import result of both files is the same (a texture), if you replace e.g. a texture with a mesh stuff will break. This also works for e.g. swapping out an OBJ file with a matching FBX, etc. ===== Swapping out a Prefab with another one ===== This is a bit more involved and will only work in specific cases. _Prefabs_ in Unity have both a guid (which identifies the prefab) and a ton of fileIds. Every object (GameObjects, Transforms, Colliders, ...) have their own fileId. Assets in the scene are always referenced with (guid+fileId) so that there's a clear link. So, when you want to replace a prefab, you have to * replace the guid in the .prefab.meta file * replace at least the root Transform fileId in the .prefab file (this is used to place the prefab in scenes) * replace all other fileIds you want to keep intact (e.g. objects reference stuff inside the prefab, overrides you have applied to specific things, ... be careful) ===== Swapping out High-Quality and Low-Quality Versions of an Asset ===== // or: a real-world example why you would even want to do the above: // When you're careful and have defined a "Prefab Interface" as outlined above (matching GUIDs and root transform fileId between objects), you can use this for something very powerful: You can switch out all your high-resolution project assets for low-resolution project assets. ==== Example: Swapping Desktop-quality assets with 100.000 vertices ↔ Mobile-quality assets with 5.000 vertices. ==== Note that these can have different meshes, different textures, ... all that matters is that they're "dumb", that is, are only placed in a scene and not have further overrides / modifications / links. A good way to do the above is to have two Packages, // com.me.high-quality // and // com.me.low-quality // that contain // the same prefab interfaces // and otherwise all the meshes/textures required.